Skip to content

Commit

Permalink
feat: add Python 3.12 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Agrendalath committed Apr 17, 2024
1 parent 118f2f4 commit ce9cd7f
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 91 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-20.04]
python-version: ['3.8', '3.11']
python-version: ['3.8', '3.11', '3.12']
toxenv: [django42, quality, package]
steps:
- name: Install translations dependencies
Expand Down
29 changes: 14 additions & 15 deletions google_drive/tests/unit/test_calendar.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from django.utils.html import escape
from django.utils.translation import override as override_language
from mock import Mock
from nose.tools import assert_equal, assert_in
from workbench.runtime import WorkbenchRuntime
from xblock.runtime import DictKeyValueStore, KvsFieldData

Expand Down Expand Up @@ -106,14 +105,14 @@ def test_calendar_template_content(self, override, activate_lang, expected_lang)
src_url = (f'https://www.google.com/calendar/embed?mode=Month&src'
f'={DEFAULT_CALENDAR_ID}&showCalendars=0&hl={expected_lang}')

assert_in('<div class="google-calendar-xblock-wrapper">', student_fragment.content)
assert_in(escape(src_url), student_fragment.content)
assert_in('Google Calendar', student_fragment.content)
assert '<div class="google-calendar-xblock-wrapper">' in student_fragment.content
assert escape(src_url) in student_fragment.content
assert 'Google Calendar' in student_fragment.content

assert_in(STUDIO_EDIT_WRAPPER, studio_fragment.content)
assert_in(VALIDATION_WRAPPER, studio_fragment.content)
assert_in(USER_INPUTS_WRAPPER, studio_fragment.content)
assert_in(BUTTONS_WRAPPER, studio_fragment.content)
assert STUDIO_EDIT_WRAPPER in studio_fragment.content
assert VALIDATION_WRAPPER in studio_fragment.content
assert USER_INPUTS_WRAPPER in studio_fragment.content
assert BUTTONS_WRAPPER in studio_fragment.content

def test_calendar_document_submit(self):
""" Test studio submission of GoogleCalendarBlock """
Expand All @@ -122,16 +121,16 @@ def test_calendar_document_submit(self):
body = json.dumps(TEST_SUBMIT_DATA)
res = block.handle('studio_submit', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equal(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)
assert json.loads(res.body.decode('utf8')) == RESULT_SUCCESS

assert_equal(block.display_name, TEST_SUBMIT_DATA['display_name'])
assert_equal(block.calendar_id, TEST_SUBMIT_DATA['calendar_id'])
assert_equal(block.default_view, TEST_SUBMIT_DATA['default_view'])
assert block.display_name == TEST_SUBMIT_DATA['display_name']
assert block.calendar_id == TEST_SUBMIT_DATA['calendar_id']
assert block.default_view == TEST_SUBMIT_DATA['default_view']

body = json.dumps('')
res = block.handle('studio_submit', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equal(json.loads(res.body.decode('utf8')), RESULT_ERROR)
assert json.loads(res.body.decode('utf8')) == RESULT_ERROR

def test_calendar_publish_event(self):
""" Test event publishing in GoogleCalendarBlock"""
Expand All @@ -140,9 +139,9 @@ def test_calendar_publish_event(self):
body = json.dumps(TEST_COMPLETE_PUBLISH_DATA)
res = block.handle('publish_event', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equal(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)
assert json.loads(res.body.decode('utf8')) == RESULT_SUCCESS

body = json.dumps(TEST_INCOMPLETE_PUBLISH_DATA)
res = block.handle('publish_event', make_request(body))

assert_equal(json.loads(res.body.decode('utf8')), RESULT_MISSING_EVENT_TYPE)
assert json.loads(res.body.decode('utf8')) == RESULT_MISSING_EVENT_TYPE
39 changes: 19 additions & 20 deletions google_drive/tests/unit/test_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import unittest

from mock import Mock
from nose.tools import assert_equal, assert_in
from workbench.runtime import WorkbenchRuntime
from xblock.runtime import DictKeyValueStore, KvsFieldData

Expand Down Expand Up @@ -83,15 +82,15 @@ def test_document_template_content(self):

student_fragment = block.render('student_view', Mock())
# pylint: disable=no-value-for-parameter
assert_in('<div class="google-docs-xblock-wrapper"', student_fragment.content)
assert_in('Google Document', student_fragment.content)
assert_in(DEFAULT_EMBED_CODE, student_fragment.content)
assert '<div class="google-docs-xblock-wrapper"' in student_fragment.content
assert 'Google Document' in student_fragment.content
assert DEFAULT_EMBED_CODE in student_fragment.content

studio_fragment = block.render('studio_view', Mock())
assert_in(STUDIO_EDIT_WRAPPER, studio_fragment.content)
assert_in(VALIDATION_WRAPPER, studio_fragment.content)
assert_in(USER_INPUTS_WRAPPER, studio_fragment.content)
assert_in(BUTTONS_WRAPPER, studio_fragment.content)
assert STUDIO_EDIT_WRAPPER in studio_fragment.content
assert VALIDATION_WRAPPER in studio_fragment.content
assert USER_INPUTS_WRAPPER in studio_fragment.content
assert BUTTONS_WRAPPER in studio_fragment.content

def test_studio_document_submit(self):
""" Test studio submission of GoogleDocumentBlock """
Expand All @@ -100,15 +99,15 @@ def test_studio_document_submit(self):
body = json.dumps(TEST_SUBMIT_DATA)
res = block.handle('studio_submit', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equal(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)
assert json.loads(res.body.decode('utf8')) == RESULT_SUCCESS

assert_equal(block.display_name, TEST_SUBMIT_DATA['display_name'])
assert_equal(block.embed_code, TEST_SUBMIT_DATA['embed_code'])
assert_equal(block.alt_text, TEST_SUBMIT_DATA['alt_text'])
assert block.display_name == TEST_SUBMIT_DATA['display_name']
assert block.embed_code == TEST_SUBMIT_DATA['embed_code']
assert block.alt_text == TEST_SUBMIT_DATA['alt_text']

body = json.dumps('')
res = block.handle('studio_submit', make_request(body))
assert_equal(json.loads(res.body.decode('utf8')), RESULT_ERROR)
assert json.loads(res.body.decode('utf8')) == RESULT_ERROR

def test_check_document_url(self):
""" Test verification of the provided Google Document URL"""
Expand All @@ -117,22 +116,22 @@ def test_check_document_url(self):
data = json.dumps(TEST_VALIDATE_URL_DATA)
res = block.handle('check_url', make_request(data))
# pylint: disable=no-value-for-parameter
assert_equal(json.loads(res.body.decode('utf8')), STATUS_CODE_200)
assert json.loads(res.body.decode('utf8')) == STATUS_CODE_200

data = json.dumps(TEST_VALIDATE_UNDEFINED_DATA)
res = block.handle('check_url', make_request(data))

assert_equal(json.loads(res.body.decode('utf8')), STATUS_CODE_400)
assert json.loads(res.body.decode('utf8')) == STATUS_CODE_400

data = json.dumps(TEST_VALIDATE_NONEXISTENT_URL_DATA)
res = block.handle('check_url', make_request(data))

assert_equal(json.loads(res.body.decode('utf8')), STATUS_CODE_404)
assert json.loads(res.body.decode('utf8')) == STATUS_CODE_404

data = json.dumps({})
res = block.handle('check_url', make_request(data))

assert_equal(json.loads(res.body.decode('utf8')), STATUS_CODE_400)
assert json.loads(res.body.decode('utf8')) == STATUS_CODE_400

def test_document_publish_event(self):
""" Test event publishing in GoogleDocumentBlock"""
Expand All @@ -141,14 +140,14 @@ def test_document_publish_event(self):
body = json.dumps(TEST_COMPLETE_PUBLISH_DOCUMENT_DATA)
res = block.handle('publish_event', make_request(body))
# pylint: disable=no-value-for-parameter
assert_equal(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)
assert json.loads(res.body.decode('utf8')) == RESULT_SUCCESS

body = json.dumps(TEST_COMPLETE_PUBLISH_IMAGE_DATA)
res = block.handle('publish_event', make_request(body))

assert_equal(json.loads(res.body.decode('utf8')), RESULT_SUCCESS)
assert json.loads(res.body.decode('utf8')) == RESULT_SUCCESS

body = json.dumps(TEST_INCOMPLETE_PUBLISH_DATA)
res = block.handle('publish_event', make_request(body))

assert_equal(json.loads(res.body.decode('utf8')), RESULT_MISSING_EVENT_TYPE)
assert json.loads(res.body.decode('utf8')) == RESULT_MISSING_EVENT_TYPE
12 changes: 6 additions & 6 deletions requirements/ci.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,21 +32,21 @@ django==4.2.11
# edx-i18n-tools
docopt==0.6.2
# via coveralls
edx-i18n-tools==1.3.0
edx-i18n-tools==1.5.0
# via -r requirements/ci.in
filelock==3.13.3
filelock==3.13.4
# via
# tox
# virtualenv
idna==3.6
idna==3.7
# via requests
lxml==5.2.1
# via edx-i18n-tools
packaging==24.0
# via
# pyproject-api
# tox
path==16.13.0
path==16.14.0
# via edx-i18n-tools
platformdirs==4.2.0
# via
Expand All @@ -62,7 +62,7 @@ pyyaml==6.0.1
# via edx-i18n-tools
requests==2.31.0
# via coveralls
sqlparse==0.4.4
sqlparse==0.5.0
# via django
tomli==2.0.1
# via
Expand All @@ -74,5 +74,5 @@ typing-extensions==4.11.0
# via asgiref
urllib3==2.2.1
# via requests
virtualenv==20.25.1
virtualenv==20.25.2
# via tox
23 changes: 8 additions & 15 deletions requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ backports-zoneinfo==0.2.1 ; python_version < "3.9"
# django
binaryornot==0.4.4
# via cookiecutter
boto3==1.34.79
boto3==1.34.85
# via fs-s3fs
botocore==1.34.79
botocore==1.34.85
# via
# boto3
# s3transfer
Expand Down Expand Up @@ -57,7 +57,7 @@ coverage[toml]==7.4.4
# via pytest-cov
ddt==1.7.2
# via -r requirements/test.in
diff-cover==8.0.3
diff-cover==9.0.0
# via -r requirements/dev.in
dill==0.3.8
# via pylint
Expand All @@ -70,7 +70,7 @@ django==4.2.11
# edx-i18n-tools
# openedx-django-pyfs
# xblock-sdk
edx-i18n-tools==1.3.0
edx-i18n-tools==1.5.0
# via -r requirements/test.in
edx-lint==5.3.6
# via -r requirements/quality.in
Expand All @@ -85,7 +85,7 @@ fs-s3fs==1.1.1
# via
# openedx-django-pyfs
# xblock-sdk
idna==3.6
idna==3.7
# via requests
importlib-metadata==6.11.0
# via
Expand Down Expand Up @@ -113,7 +113,7 @@ lxml==4.9.4
# edx-i18n-tools
# xblock
# xblock-sdk
mako==1.3.2
mako==1.3.3
# via xblock
markdown-it-py==3.0.0
# via rich
Expand All @@ -128,16 +128,14 @@ mdurl==0.1.2
# via markdown-it-py
mock==5.1.0
# via -r requirements/test.in
nose==1.3.7
# via -r requirements/test.in
openedx-django-pyfs==3.6.0
# via xblock
packaging==24.0
# via
# build
# caniusepython3
# pytest
path==16.13.0
path==16.14.0
# via edx-i18n-tools
pbr==6.0.0
# via stevedore
Expand Down Expand Up @@ -199,7 +197,6 @@ python-slugify==8.0.4
# via
# code-annotations
# cookiecutter
# transifex-client
pytz==2024.1
# via xblock
pyyaml==6.0.1
Expand All @@ -213,7 +210,6 @@ requests==2.31.0
# -r requirements/base.in
# caniusepython3
# cookiecutter
# transifex-client
# xblock-sdk
rich==13.7.1
# via cookiecutter
Expand All @@ -229,12 +225,9 @@ six==1.16.0
# fs
# fs-s3fs
# python-dateutil
# transifex-client
smmap==5.0.1
# via gitdb
snowballstemmer==2.2.0
# via pydocstyle
sqlparse==0.4.4
sqlparse==0.5.0
# via django
stevedore==5.2.0
# via code-annotations
Expand Down
2 changes: 1 addition & 1 deletion requirements/pip.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ wheel==0.43.0
# The following packages are considered to be unsafe in a requirements file:
pip==24.0
# via -r requirements/pip.in
setuptools==69.2.0
setuptools==69.5.1
# via -r requirements/pip.in
Loading

0 comments on commit ce9cd7f

Please sign in to comment.