Skip to content
This repository has been archived by the owner on May 12, 2022. It is now read-only.

Commit

Permalink
Merge pull request #219 from eduNEXT/lmm/py38
Browse files Browse the repository at this point in the history
[BD-6] Upgrade requirements and add python 3.8 tests
  • Loading branch information
awais786 authored May 8, 2020
2 parents ef448f5 + ceffc23 commit 11273ab
Show file tree
Hide file tree
Showing 20 changed files with 125 additions and 117 deletions.
20 changes: 12 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
language: python

matrix:
include:
- python: "3.5"
env: DJANGO_SETTINGS_MODULE=settings
script:
- tox -e py35
- ./node_modules/gulp/bin/gulp.js test
- bash ./run_bokchoy_tests.sh
python:
- 3.5
- 3.8

envs:
- TOXENV=django22
- TOXENV=quality

script:
- tox
- ./node_modules/gulp/bin/gulp.js test
- bash ./run_bokchoy_tests.sh

addons:
firefox: "46.0"
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@ upgrade: ## update the requirements/*.txt files with the latest packages satisfy
pip install -q pip-tools
pip-compile --upgrade -o requirements/base.txt requirements/base.in
pip-compile --upgrade -o requirements/testing.txt requirements/testing.in
# Let tox control the Django version for tests
grep -e "^django==" requirements/base.txt > requirements/django.txt
sed -i.tmp '/^[dD]jango==/d' requirements/testing.txt
rm requirements/testing.txt.tmp

5 changes: 2 additions & 3 deletions edx_notifications/base_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ class Dict(dict):
Create a subclass of dict to make it weak referencable
per https://docs.python.org/2/library/weakref.html
"""
pass


class TypedField(object):
class TypedField:
"""
Field Decscriptors used to enforce correct typing
"""
Expand Down Expand Up @@ -417,7 +416,7 @@ def validate(self):
Validations should throw a ValidationError if there
is a problem.
"""
pass # this intentionally does nothing
# this intentionally does nothing


class RelatedObjectField(TypedField):
Expand Down
2 changes: 1 addition & 1 deletion edx_notifications/channels/link_resolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def resolve(self, msg_type_name, link_name, params, exact_match_only=False):
return None


class MsgTypeToUrlResolverMixin(object):
class MsgTypeToUrlResolverMixin:
"""
Helper mix-in class to share logic when channels need to use
similar link resolvers
Expand Down
2 changes: 1 addition & 1 deletion edx_notifications/channels/tests/test_parse_push.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from edx_notifications.channels.parse_push import _PARSE_SERVICE_USER_ID, ParsePushNotificationChannelProvider


class MockCrashingParsePush(object):
class MockCrashingParsePush:
"""
Simulate an exception
"""
Expand Down
6 changes: 3 additions & 3 deletions edx_notifications/lib/tests/test_lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def test_bulk_publish_list(self):

# now send to more than our internal chunking size
bulk_publish_notification_to_users(
[user_id for user_id in range(1, const.NOTIFICATION_BULK_PUBLISH_CHUNK_SIZE * 2 + 1)],
list(range(1, const.NOTIFICATION_BULK_PUBLISH_CHUNK_SIZE * 2 + 1)),
msg
)

Expand Down Expand Up @@ -282,8 +282,8 @@ def test_bulk_publish_list_exclude(self):
}
)

user_ids = [user_id for user_id in range(1, const.NOTIFICATION_BULK_PUBLISH_CHUNK_SIZE * 2 + 1)]
exclude_user_ids = [user_id for user_id in range(1, const.NOTIFICATION_BULK_PUBLISH_CHUNK_SIZE * 2 + 1, 2)]
user_ids = list(range(1, const.NOTIFICATION_BULK_PUBLISH_CHUNK_SIZE * 2 + 1))
exclude_user_ids = list(range(1, const.NOTIFICATION_BULK_PUBLISH_CHUNK_SIZE * 2 + 1, 2))

# now send to more than our internal chunking size
bulk_publish_notification_to_users(
Expand Down
2 changes: 1 addition & 1 deletion edx_notifications/openedx/group_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
GROUP_PROJECT_RENDERER_PREFIX = 'edx_notifications.openedx.group_project'


class NotificationMessageTypes(object):
class NotificationMessageTypes:
"""
Message type constants
"""
Expand Down
2 changes: 1 addition & 1 deletion edx_notifications/renderers/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class UnderscoreStaticFileRenderer(BaseNotificationRenderer):
underscore_template_name = None
underscore_template = None

def __init__(self, template_name=None):
def __init__(self, template_name=None): # pylint: disable=super-init-not-called
"""
Initializer
"""
Expand Down
2 changes: 1 addition & 1 deletion edx_notifications/scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def resolve(self, scope_name, scope_context, instance_context):
raise NotImplementedError()


class SingleUserScopeResolver(object):
class SingleUserScopeResolver:
"""
Simple implementation for scope_name='user' where there must
be a user_id inside the scope_context
Expand Down
2 changes: 1 addition & 1 deletion edx_notifications/server/api/consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_parameters_from_request(request, allowed_parameters):
raise ValueError(
"Passed in expected bool '{val}' does not map to True or False".format(val=str_val)
)
elif filter_type == str or filter_type == six.text_type:
elif filter_type in (str, six.text_type):
value = str_val
else:
raise ValueError('Unknown parameter type {name}'.format(name=filter_type))
Expand Down
16 changes: 8 additions & 8 deletions edx_notifications/stores/sql/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SQLNotificationType(models.Model):
# any context to pass into the above renderer
renderer_context = models.TextField(null=True)

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand Down Expand Up @@ -102,7 +102,7 @@ class SQLNotificationMessage(TimeStampedModel):

object_id = models.CharField(max_length=255, db_index=True, null=True)

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand Down Expand Up @@ -177,7 +177,7 @@ class SQLUserNotificationArchive(TimeStampedModel):

user_context = models.TextField(null=True)

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand All @@ -200,7 +200,7 @@ class SQLUserNotification(TimeStampedModel):

user_context = models.TextField(null=True)

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand Down Expand Up @@ -251,7 +251,7 @@ class SQLNotificationChannel(models.Model):
SMS, iOS Push Notifications, etc.
"""

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand All @@ -263,7 +263,7 @@ class SQLNotificationPreference(models.Model):
"""
Notification preference
"""
class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand Down Expand Up @@ -317,7 +317,7 @@ class SQLUserNotificationPreferences(TimeStampedModel):
User specific mappings of Notifications to Channel, to reflect user preferences
"""

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand Down Expand Up @@ -367,7 +367,7 @@ class SQLNotificationCallbackTimer(TimeStampedModel):
SQL implementation for NotificationCallbackTimer
"""

class Meta(object):
class Meta:
"""
ORM metadata about this class
"""
Expand Down
10 changes: 5 additions & 5 deletions edx_notifications/tests/test_scopes.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def resolve(self, scope_name, scope_context, instance_context):
"""

if scope_name == 'list_scope':
return [num for num in range(scope_context['range'])]
return list(range(scope_context['range']))

if scope_name == 'badtype_scope':
return 1
Expand Down Expand Up @@ -71,7 +71,7 @@ def resolve(self, scope_name, scope_context, instance_context):

if scope_name == 'values_list_query_set':
return User.objects.values_list('id', flat=True).all() # pylint: disable=no-member
elif scope_name == 'values_query_set':
if scope_name == 'values_query_set':
return User.objects.values('id').all() # pylint: disable=no-member
return None

Expand Down Expand Up @@ -116,7 +116,7 @@ def test_resolving_scope(self):

self.assertIsNotNone(user_ids)
self.assertEqual(len(user_ids), 5)
self.assertEqual(user_ids, [num for num in range(5)])
self.assertEqual(user_ids, list(range(5)))

user_ids = resolve_user_scope('generator_scope', {'range': 10})

Expand All @@ -126,7 +126,7 @@ def test_resolving_scope(self):
compare.append(user_id)

# generators dont support len()
self.assertEqual(compare, [num for num in range(10)])
self.assertEqual(compare, list(range(10)))

def test_no_resolve(self):
"""
Expand Down Expand Up @@ -193,7 +193,7 @@ def test_django_orm_based_resolver(self):
"""

users = resolve_user_scope('values_list_query_set', {})
users_list = [user for user in users]
users_list = list(users)
self.assertEqual(len(users_list), 1)
self.assertEqual(users_list[0], self.test_user.id)

Expand Down
2 changes: 1 addition & 1 deletion requirements/base.in
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Django/Framework Packages
django<2.3
django-model-utils==2.3.1
python-dateutil==2.1
python-dateutil
requests==2.22.0
pylru==1.0.6
djangorestframework==3.11.0
Expand Down
36 changes: 18 additions & 18 deletions requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,26 @@
#
# make upgrade
#
beautifulsoup4==4.8.2 # via pynliner
certifi==2019.11.28 # via requests
beautifulsoup4==4.9.0 # via pynliner
certifi==2020.4.5.1 # via requests
chardet==3.0.4 # via requests
cssutils==1.0.2 # via pynliner
decorator==4.4.1 # via pycontracts
django-model-utils==2.3.1 # via -r requirements/base.in (line 3)
django==2.2.10 # via -r requirements/base.in (line 2), django-model-utils, djangorestframework
djangorestframework==3.11.0 # via -r requirements/base.in (line 7)
freezegun==0.3.12 # via -r requirements/base.in (line 12)
decorator==4.4.2 # via pycontracts
django-model-utils==2.3.1 # via -r requirements/base.in
django==2.2.12 # via -r requirements/base.in, django-model-utils, djangorestframework
djangorestframework==3.11.0 # via -r requirements/base.in
freezegun==0.3.15 # via -r requirements/base.in
idna==2.8 # via requests
git+https://github.com/milesrichardson/ParsePy.git # via -r requirements/base.in (line 11)
pycontracts==1.7.1 # via -r requirements/base.in (line 8)
pylru==1.0.6 # via -r requirements/base.in (line 6)
pynliner==0.8.0 # via -r requirements/base.in (line 10)
pyparsing==2.4.6 # via pycontracts
python-dateutil==2.1 # via -r requirements/base.in (line 4), freezegun
pytz==2019.3 # via django
requests==2.22.0 # via -r requirements/base.in (line 5)
git+https://github.com/milesrichardson/ParsePy.git # via -r requirements/base.in
pycontracts==1.7.1 # via -r requirements/base.in
pylru==1.0.6 # via -r requirements/base.in
pynliner==0.8.0 # via -r requirements/base.in
pyparsing==2.4.7 # via pycontracts
python-dateutil==2.8.1 # via -r requirements/base.in, freezegun
pytz==2020.1 # via django
requests==2.22.0 # via -r requirements/base.in
six==1.14.0 # via freezegun, parse-rest, python-dateutil
soupsieve==2.0 # via beautifulsoup4
sqlparse==0.3.0 # via django
underscore.py==0.1.6 # via -r requirements/base.in (line 9)
urllib3==1.25.8 # via requests
sqlparse==0.3.1 # via django
underscore.py==0.1.6 # via -r requirements/base.in
urllib3==1.25.9 # via requests
1 change: 1 addition & 0 deletions requirements/django.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
django==2.2.12 # via -r requirements/base.in, django-model-utils, djangorestframework
16 changes: 8 additions & 8 deletions requirements/testing.in
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
-r base.txt # Core dependencies for this package

# Testing Packages
coverage==4.0.2
astroid==1.6.6
django_nose==1.4.5
nose==1.3.7
coverage
astroid
django_nose
nose
httpretty==0.9.7
pep8==1.5.7
pylint==1.9.5
pep257==0.3.2
pycodestyle
pylint
pydocstyle
mock==1.0.1
testfixtures==4.5.0
bok-choy==0.6.2
sure==1.2.3
ddt==0.8.0
selenium==2.53.1
tox==3.7.0
tox
Loading

0 comments on commit 11273ab

Please sign in to comment.