From 507b36e3a6835a2902b3e6183e7c29f9fd352e3a Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 31 May 2019 13:29:07 -0400 Subject: [PATCH 01/11] Update coverage to a newer version. --- setup.py | 4 +++- test_requirements.txt | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.py b/setup.py index bf1e5c22..d56ab9d4 100755 --- a/setup.py +++ b/setup.py @@ -1,5 +1,7 @@ #!/usr/bin/env python +from __future__ import absolute_import +from __future__ import unicode_literals from setuptools import setup, find_packages from milestones import __version__ as VERSION @@ -27,7 +29,7 @@ "edx-opaque-keys>=0.2.1,<1.0.0", ], tests_require=[ - "coverage==3.7.1", + "coverage==4.5.3", "nose==1.3.3", "httpretty==0.8.0", "pep8==1.5.7", diff --git a/test_requirements.txt b/test_requirements.txt index 2dd73329..6b54db75 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,6 +1,6 @@ astroid==1.3.8 # Pinning to avoid backwards incompatibility issue with pylint/pylint-django coveralls -coverage==3.7.1 +coverage==4.5.3 django_nose>=1.4.1 nose==1.3.3 httpretty==0.8.0 From 409a6bebac9190f7ec0cf75be4800ebcd3d3bd58 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 31 May 2019 13:30:08 -0400 Subject: [PATCH 02/11] Stop testing on django 1.8 --- tox.ini | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tox.ini b/tox.ini index 0884ff6e..7c044203 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py36-django{18,111} +envlist = py27,py36-django{111} [testenv] setenv = @@ -7,7 +7,6 @@ setenv = PYTHONPATH = {toxinidir} deps = - django18: Django>=1.8,<1.9 django111: Django>=1.11,<2.0 -rtest_requirements.txt From 5cd8569989238e585d0183adda1fcf3d5d5e50d5 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Fri, 31 May 2019 13:55:50 -0400 Subject: [PATCH 03/11] Run python modernize on the repo. Specifically: `python-modernize --future-unicode -w .` Tests are still failing but making this a separate commit for cleanliness. --- manage.py | 2 ++ milestones/__init__.py | 1 + milestones/admin.py | 2 ++ milestones/api.py | 2 ++ milestones/data.py | 1 + milestones/exceptions.py | 2 ++ milestones/management/__init__.py | 2 ++ milestones/management/commands/__init__.py | 2 ++ milestones/management/commands/tests/__init__.py | 2 ++ milestones/migrations/0001_initial.py | 1 + .../migrations/0002_data__seed_relationship_types.py | 1 + .../0003_coursecontentmilestone_requirements.py | 1 + milestones/migrations/0004_auto_20151221_1445.py | 1 + milestones/migrations/__init__.py | 2 ++ milestones/models.py | 12 +++++++----- milestones/resources.py | 2 ++ milestones/serializers.py | 2 ++ milestones/services.py | 2 ++ milestones/tests/__init__.py | 2 ++ milestones/tests/mocks/__init__.py | 2 ++ milestones/tests/mocks/resources.py | 2 ++ milestones/tests/test_api.py | 1 + milestones/tests/test_data.py | 1 + milestones/tests/test_services.py | 2 ++ milestones/tests/utils.py | 2 ++ milestones/urls.py | 2 ++ milestones/validators.py | 1 + milestones/views.py | 2 ++ settings.py | 1 + 29 files changed, 53 insertions(+), 5 deletions(-) diff --git a/manage.py b/manage.py index f9726f9e..e979b3ff 100755 --- a/manage.py +++ b/manage.py @@ -1,4 +1,6 @@ #!/usr/bin/env python +from __future__ import absolute_import +from __future__ import unicode_literals import os import sys diff --git a/milestones/__init__.py b/milestones/__init__.py index 771dd3cf..5718ea9a 100644 --- a/milestones/__init__.py +++ b/milestones/__init__.py @@ -1,4 +1,5 @@ """ Milestones app initialization module """ +from __future__ import unicode_literals __version__ = '0.1.13' diff --git a/milestones/admin.py b/milestones/admin.py index 8341249c..9e4eb04e 100644 --- a/milestones/admin.py +++ b/milestones/admin.py @@ -1,6 +1,8 @@ """ Admin module for milestones app """ +from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib import admin from milestones.models import ( diff --git a/milestones/api.py b/milestones/api.py index 10631d3c..b07d1a81 100644 --- a/milestones/api.py +++ b/milestones/api.py @@ -12,6 +12,8 @@ Note the terminology difference at this layer vs. Data -- add/edit/get/remove """ +from __future__ import absolute_import +from __future__ import unicode_literals from . import data from . import exceptions from . import validators diff --git a/milestones/data.py b/milestones/data.py index c02acd53..f6ccdc1b 100644 --- a/milestones/data.py +++ b/milestones/data.py @@ -25,6 +25,7 @@ import milestones.resources as remote """ from __future__ import absolute_import +from __future__ import unicode_literals from . import exceptions from . import models as internal from . import serializers diff --git a/milestones/exceptions.py b/milestones/exceptions.py index 8200f7e9..cc8f3ee0 100644 --- a/milestones/exceptions.py +++ b/milestones/exceptions.py @@ -1,6 +1,8 @@ """ Application-specific exception classes used throughout the implementation """ +from __future__ import absolute_import +from __future__ import unicode_literals from django.core.exceptions import ValidationError diff --git a/milestones/management/__init__.py b/milestones/management/__init__.py index 2c19983d..7a6e264a 100644 --- a/milestones/management/__init__.py +++ b/milestones/management/__init__.py @@ -1,3 +1,5 @@ """ Milestones management package initialization module """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/management/commands/__init__.py b/milestones/management/commands/__init__.py index 4716c2ea..c257c7c5 100644 --- a/milestones/management/commands/__init__.py +++ b/milestones/management/commands/__init__.py @@ -1,3 +1,5 @@ """ Milestones management commands package initialization module """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/management/commands/tests/__init__.py b/milestones/management/commands/tests/__init__.py index 98e6196a..b036eaeb 100644 --- a/milestones/management/commands/tests/__init__.py +++ b/milestones/management/commands/tests/__init__.py @@ -1,3 +1,5 @@ """ Milestones management commands tests package initialization module """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/migrations/0001_initial.py b/milestones/migrations/0001_initial.py index fa5f353f..3f449261 100644 --- a/milestones/migrations/0001_initial.py +++ b/milestones/migrations/0001_initial.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import from django.db import models, migrations import django.utils.timezone import model_utils.fields diff --git a/milestones/migrations/0002_data__seed_relationship_types.py b/milestones/migrations/0002_data__seed_relationship_types.py index 532fd9e1..9e74bef8 100644 --- a/milestones/migrations/0002_data__seed_relationship_types.py +++ b/milestones/migrations/0002_data__seed_relationship_types.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import from django.db import migrations, models from milestones.data import fetch_milestone_relationship_types diff --git a/milestones/migrations/0003_coursecontentmilestone_requirements.py b/milestones/migrations/0003_coursecontentmilestone_requirements.py index 168b289e..14e037df 100644 --- a/milestones/migrations/0003_coursecontentmilestone_requirements.py +++ b/milestones/migrations/0003_coursecontentmilestone_requirements.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import from django.db import migrations, models diff --git a/milestones/migrations/0004_auto_20151221_1445.py b/milestones/migrations/0004_auto_20151221_1445.py index f4dff7ab..9ce68b2c 100644 --- a/milestones/migrations/0004_auto_20151221_1445.py +++ b/milestones/migrations/0004_auto_20151221_1445.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals +from __future__ import absolute_import from django.db import migrations, models diff --git a/milestones/migrations/__init__.py b/milestones/migrations/__init__.py index 9f1d05d7..0122ec0f 100644 --- a/milestones/migrations/__init__.py +++ b/milestones/migrations/__init__.py @@ -1,3 +1,5 @@ """ Milestones migrations package initialization module """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/models.py b/milestones/models.py index be1066ce..8d052f71 100644 --- a/milestones/models.py +++ b/milestones/models.py @@ -8,6 +8,8 @@ which leverages Django's signal framework. """ +from __future__ import absolute_import +from __future__ import unicode_literals from django.db import models from model_utils.models import TimeStampedModel @@ -32,7 +34,7 @@ class Meta: unique_together = (("namespace", "name"),) def __unicode__(self): - return unicode(self.namespace) + return str(self.namespace) class MilestoneRelationshipType(TimeStampedModel): @@ -61,7 +63,7 @@ class MilestoneRelationshipType(TimeStampedModel): active = models.BooleanField(default=True) def __unicode__(self): - return unicode(self.name) + return str(self.name) @classmethod # pylint: disable=invalid-name @@ -94,7 +96,7 @@ class Meta: unique_together = (("course_id", "milestone"),) def __unicode__(self): - return unicode("%s:%s:%s" % (self.course_id, self.milestone_relationship_type, self.milestone)) + return str("%s:%s:%s" % (self.course_id, self.milestone_relationship_type, self.milestone)) class CourseContentMilestone(TimeStampedModel): @@ -125,7 +127,7 @@ class Meta: unique_together = (("course_id", "content_id", "milestone"),) def __unicode__(self): - return unicode("%s:%s:%s" % (self.content_id, self.milestone_relationship_type, self.milestone)) + return str("%s:%s:%s" % (self.content_id, self.milestone_relationship_type, self.milestone)) class UserMilestone(TimeStampedModel): @@ -154,4 +156,4 @@ class Meta: unique_together = ("user_id", "milestone") def __unicode__(self): - return unicode("%s:%s" % (self.user_id, self.milestone)) + return str("%s:%s" % (self.user_id, self.milestone)) diff --git a/milestones/resources.py b/milestones/resources.py index 30d8433d..e78a9ae9 100644 --- a/milestones/resources.py +++ b/milestones/resources.py @@ -12,3 +12,5 @@ This module should only be called directly by data.py, in order to maintain the intended data layer abstractions/contracts. """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/serializers.py b/milestones/serializers.py index 57b9d43b..39cb67ca 100644 --- a/milestones/serializers.py +++ b/milestones/serializers.py @@ -2,6 +2,8 @@ Data layer serialization operations. Converts querysets to simple python containers (mainly arrays and dicts). """ +from __future__ import absolute_import +from __future__ import unicode_literals import json from . import models diff --git a/milestones/services.py b/milestones/services.py index b14fb359..926a2ea1 100644 --- a/milestones/services.py +++ b/milestones/services.py @@ -2,6 +2,8 @@ A wrapper class around requested methods exposed in api.py """ +from __future__ import absolute_import +from __future__ import unicode_literals import types from milestones import api as milestones_api diff --git a/milestones/tests/__init__.py b/milestones/tests/__init__.py index 4ec89e7d..b194b1d5 100644 --- a/milestones/tests/__init__.py +++ b/milestones/tests/__init__.py @@ -1,3 +1,5 @@ """ Milestones Tests initialization module """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/tests/mocks/__init__.py b/milestones/tests/mocks/__init__.py index 3bc2611a..144ce4df 100644 --- a/milestones/tests/mocks/__init__.py +++ b/milestones/tests/mocks/__init__.py @@ -1 +1,3 @@ """ Milestones Tests Mocks initialization module """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/tests/mocks/resources.py b/milestones/tests/mocks/resources.py index 70315c41..62a762f5 100644 --- a/milestones/tests/mocks/resources.py +++ b/milestones/tests/mocks/resources.py @@ -1,3 +1,5 @@ """ Mock implementations of remote dependencies for test isolation """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/tests/test_api.py b/milestones/tests/test_api.py index 322b6be8..b54f9be7 100644 --- a/milestones/tests/test_api.py +++ b/milestones/tests/test_api.py @@ -5,6 +5,7 @@ Milestones API Module Test Cases """ from __future__ import absolute_import +from __future__ import unicode_literals from opaque_keys.edx.keys import UsageKey import milestones.api as api diff --git a/milestones/tests/test_data.py b/milestones/tests/test_data.py index 019d7d56..b752f9f7 100644 --- a/milestones/tests/test_data.py +++ b/milestones/tests/test_data.py @@ -6,6 +6,7 @@ Note: 'Unit Test: ' labels are output to the console during test runs """ from __future__ import absolute_import +from __future__ import unicode_literals import milestones.api as api import milestones.data as data import milestones.exceptions as exceptions diff --git a/milestones/tests/test_services.py b/milestones/tests/test_services.py index 08dd711f..af786aa0 100644 --- a/milestones/tests/test_services.py +++ b/milestones/tests/test_services.py @@ -2,6 +2,8 @@ Test for the xBlock service """ +from __future__ import absolute_import +from __future__ import unicode_literals import unittest import types diff --git a/milestones/tests/utils.py b/milestones/tests/utils.py index a90ffd81..a04de96a 100644 --- a/milestones/tests/utils.py +++ b/milestones/tests/utils.py @@ -2,6 +2,8 @@ """ Utility module for Milestones test cases """ +from __future__ import absolute_import +from __future__ import unicode_literals from django.contrib.auth.models import User from django.test import TestCase from opaque_keys.edx.keys import CourseKey, UsageKey diff --git a/milestones/urls.py b/milestones/urls.py index feb455c9..a581115f 100644 --- a/milestones/urls.py +++ b/milestones/urls.py @@ -1,3 +1,5 @@ """ urls.py -- useful some day when views.py comes alive """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/milestones/validators.py b/milestones/validators.py index 5192ac92..12a35a73 100644 --- a/milestones/validators.py +++ b/milestones/validators.py @@ -2,6 +2,7 @@ Validators confirm the integrity of inbound information prior to a data.py handoff """ from __future__ import absolute_import +from __future__ import unicode_literals import json from opaque_keys import InvalidKeyError diff --git a/milestones/views.py b/milestones/views.py index c6f34157..5e071fff 100644 --- a/milestones/views.py +++ b/milestones/views.py @@ -6,3 +6,5 @@ In this particular application, the views simply hand-off to the orchestration layer, which manages the application's workflows. """ + +from __future__ import unicode_literals \ No newline at end of file diff --git a/settings.py b/settings.py index 64e17d21..2181accb 100644 --- a/settings.py +++ b/settings.py @@ -1,3 +1,4 @@ +from __future__ import unicode_literals DEBUG=True TEST_MODE=True TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' From d1d8c6afe5aedd6856a6561059486c4f33234493 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 3 Jun 2019 10:00:50 -0400 Subject: [PATCH 04/11] Fix failing tests. We don't need to decode the unicod and then re-encode it since with unicode literals it's just always unicode. --- milestones/api.py | 2 +- milestones/tests/test_api.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/milestones/api.py b/milestones/api.py index b07d1a81..a88bdbeb 100644 --- a/milestones/api.py +++ b/milestones/api.py @@ -220,7 +220,7 @@ def get_course_milestones_fulfillment_paths(course_key, user): # Build the set of fulfillment paths for the outstanding milestones fulfillment_paths = {} for milestone in required_milestones: - dict_key = '{}.{}'.format(milestone['namespace'].encode('utf-8'), milestone['name'].encode('utf-8')) + dict_key = '{}.{}'.format(milestone['namespace'], milestone['name']) fulfillment_paths[dict_key] = {} milestone_courses = data.fetch_milestone_courses( milestone, diff --git a/milestones/tests/test_api.py b/milestones/tests/test_api.py index b54f9be7..e30abd48 100644 --- a/milestones/tests/test_api.py +++ b/milestones/tests/test_api.py @@ -6,6 +6,7 @@ """ from __future__ import absolute_import from __future__ import unicode_literals + from opaque_keys.edx.keys import UsageKey import milestones.api as api From 0765b0532f61f326b3d67d16683c988591971a1c Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 3 Jun 2019 10:04:23 -0400 Subject: [PATCH 05/11] Update openedx.yaml --- openedx.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openedx.yaml b/openedx.yaml index 35a7e6e5..16da1cd9 100644 --- a/openedx.yaml +++ b/openedx.yaml @@ -1,5 +1,5 @@ oeps: - oep-7: false + oep-7: true oep-18: false tags: From d1c97ff9021dd7ceaa3a7aab09f1133f7dcdc76f Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 3 Jun 2019 10:15:52 -0400 Subject: [PATCH 06/11] Update test config. --- .travis.yml | 19 +++++++++++-------- tox.ini | 2 +- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index b12b4772..fb93f7b9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,32 +1,35 @@ language: python + python: - 2.7 +- 3.6 + env: -- TOXENV=django18 - TOXENV=django111 + matrix: include: - - python: 2.7 - env: TOXENV=quality - python: 3.6 - env: TOXENV=py36 - allow_failures: - - python: 3.6 + env: TOXENV=quality + before_install: - export DJANGO_SETTINGS_MODULE=settings + install: - make install -sudo: false + script: - make test + after_success: coveralls + deploy: provider: pypi user: edx distributions: sdist bdist_wheel on: tags: true - python: 2.7 + python: 3.6 condition: '$TOXENV = django111' password: secure: oVeS9OrvR5XvJMg86eO004xk9KFh9IbUxWqyWYYFZf1drtrzG2Bm7+F0BgF1hY2l+qyHXinPCCeBmV9CEfav80se1r8K0JFu9MwBHQkvaeBAJV+ItQ2ZumtgNNONoL5VZHIRbEYwl/lbZCWaXpmDLkJSlRVYCECP2bH+RcZkbQM= diff --git a/tox.ini b/tox.ini index 7c044203..16241db5 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py36-django{111} +envlist = py{27,36}-django{111} [testenv] setenv = From 50272001c8054950f28b0b536c25aba66062a8d6 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 3 Jun 2019 11:04:10 -0400 Subject: [PATCH 07/11] Update gitignore. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 42b92c3e..4afb5629 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ # Packaging files: *.eggs +*.egg-info # Installation artifacts src From f9f6ae12858a8dfd06c7f4c2bf5bbbda92ffa61b Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 3 Jun 2019 11:08:03 -0400 Subject: [PATCH 08/11] Fix pylint violations. --- milestones/data.py | 6 ++++-- milestones/management/__init__.py | 2 +- milestones/management/commands/__init__.py | 2 +- milestones/management/commands/tests/__init__.py | 2 +- milestones/migrations/__init__.py | 2 +- milestones/resources.py | 2 +- milestones/tests/__init__.py | 2 +- milestones/tests/mocks/__init__.py | 2 +- milestones/tests/mocks/resources.py | 2 +- milestones/urls.py | 2 +- milestones/validators.py | 7 ++++--- milestones/views.py | 2 +- test_requirements.txt | 6 +++--- 13 files changed, 21 insertions(+), 18 deletions(-) diff --git a/milestones/data.py b/milestones/data.py index f6ccdc1b..c719117c 100644 --- a/milestones/data.py +++ b/milestones/data.py @@ -26,10 +26,12 @@ """ from __future__ import absolute_import from __future__ import unicode_literals + +import six + from . import exceptions from . import models as internal from . import serializers -import six # PRIVATE/INTERNAL METHODS (public methods located further down) @@ -177,7 +179,7 @@ def fetch_milestone(milestone_id): exceptions.raise_exception("Milestone", {'id': milestone_id}, exceptions.InvalidMilestoneException) milestone = {'id': milestone_id} milestones = fetch_milestones(milestone) - if not len(milestones): + if not milestones: exceptions.raise_exception("Milestone", milestone, exceptions.InvalidMilestoneException) return milestones[0] diff --git a/milestones/management/__init__.py b/milestones/management/__init__.py index 7a6e264a..5a051f90 100644 --- a/milestones/management/__init__.py +++ b/milestones/management/__init__.py @@ -2,4 +2,4 @@ Milestones management package initialization module """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/management/commands/__init__.py b/milestones/management/commands/__init__.py index c257c7c5..f31873f4 100644 --- a/milestones/management/commands/__init__.py +++ b/milestones/management/commands/__init__.py @@ -2,4 +2,4 @@ Milestones management commands package initialization module """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/management/commands/tests/__init__.py b/milestones/management/commands/tests/__init__.py index b036eaeb..716ef7f8 100644 --- a/milestones/management/commands/tests/__init__.py +++ b/milestones/management/commands/tests/__init__.py @@ -2,4 +2,4 @@ Milestones management commands tests package initialization module """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/migrations/__init__.py b/milestones/migrations/__init__.py index 0122ec0f..1fb2cf03 100644 --- a/milestones/migrations/__init__.py +++ b/milestones/migrations/__init__.py @@ -2,4 +2,4 @@ Milestones migrations package initialization module """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/resources.py b/milestones/resources.py index e78a9ae9..32d8a9a3 100644 --- a/milestones/resources.py +++ b/milestones/resources.py @@ -13,4 +13,4 @@ maintain the intended data layer abstractions/contracts. """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/tests/__init__.py b/milestones/tests/__init__.py index b194b1d5..cf922430 100644 --- a/milestones/tests/__init__.py +++ b/milestones/tests/__init__.py @@ -2,4 +2,4 @@ Milestones Tests initialization module """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/tests/mocks/__init__.py b/milestones/tests/mocks/__init__.py index 144ce4df..447b1152 100644 --- a/milestones/tests/mocks/__init__.py +++ b/milestones/tests/mocks/__init__.py @@ -1,3 +1,3 @@ """ Milestones Tests Mocks initialization module """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/tests/mocks/resources.py b/milestones/tests/mocks/resources.py index 62a762f5..ca1886ea 100644 --- a/milestones/tests/mocks/resources.py +++ b/milestones/tests/mocks/resources.py @@ -2,4 +2,4 @@ Mock implementations of remote dependencies for test isolation """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/urls.py b/milestones/urls.py index a581115f..33995eaa 100644 --- a/milestones/urls.py +++ b/milestones/urls.py @@ -2,4 +2,4 @@ urls.py -- useful some day when views.py comes alive """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/milestones/validators.py b/milestones/validators.py index 12a35a73..ab36ee66 100644 --- a/milestones/validators.py +++ b/milestones/validators.py @@ -3,13 +3,14 @@ """ from __future__ import absolute_import from __future__ import unicode_literals + import json +import six from opaque_keys import InvalidKeyError from opaque_keys.edx.keys import CourseKey, UsageKey from .data import fetch_milestone_relationship_types -import six def course_key_is_valid(course_key): @@ -63,9 +64,9 @@ def milestone_data_is_valid(milestone_data): return False if 'id' in milestone_data and not milestone_data.get('id'): return False - if 'name' in milestone_data and not len(milestone_data.get('name')): + if 'name' in milestone_data and not milestone_data.get('name'): return False - if 'namespace' in milestone_data and not len(milestone_data.get('namespace')): + if 'namespace' in milestone_data and not milestone_data.get('namespace'): return False return True diff --git a/milestones/views.py b/milestones/views.py index 5e071fff..3027cd82 100644 --- a/milestones/views.py +++ b/milestones/views.py @@ -7,4 +7,4 @@ orchestration layer, which manages the application's workflows. """ -from __future__ import unicode_literals \ No newline at end of file +from __future__ import unicode_literals diff --git a/test_requirements.txt b/test_requirements.txt index 6b54db75..a2dca194 100644 --- a/test_requirements.txt +++ b/test_requirements.txt @@ -1,13 +1,13 @@ -astroid==1.3.8 # Pinning to avoid backwards incompatibility issue with pylint/pylint-django coveralls +astroid==1.5.3 +edx-lint +tox coverage==4.5.3 django_nose>=1.4.1 nose==1.3.3 httpretty==0.8.0 pep8==1.5.7 -pylint==1.2.1 pep257==0.3.2 mock==1.0.1 testfixtures==4.0.0 ddt==0.8.0 -tox>=2.3.1,<3.0.0 From a50e899e568080e99926acb7c9e9dce8e825b9e5 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 5 Jun 2019 16:35:01 -0400 Subject: [PATCH 09/11] Add six as a requirement. --- setup.py | 1 + 1 file changed, 1 insertion(+) diff --git a/setup.py b/setup.py index d56ab9d4..a7d64c74 100755 --- a/setup.py +++ b/setup.py @@ -27,6 +27,7 @@ "django>=1.8,<2.0", "django-model-utils", "edx-opaque-keys>=0.2.1,<1.0.0", + "six", ], tests_require=[ "coverage==4.5.3", From 37b80b29ff7cde87f380a2f5b6fc9a4474e5220e Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Mon, 3 Jun 2019 13:38:32 -0400 Subject: [PATCH 10/11] Prep for a new release. --- milestones/__init__.py | 2 +- setup.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/milestones/__init__.py b/milestones/__init__.py index 5718ea9a..358974d3 100644 --- a/milestones/__init__.py +++ b/milestones/__init__.py @@ -2,4 +2,4 @@ Milestones app initialization module """ from __future__ import unicode_literals -__version__ = '0.1.13' +__version__ = '0.2.0' diff --git a/setup.py b/setup.py index a7d64c74..727048d7 100755 --- a/setup.py +++ b/setup.py @@ -14,13 +14,18 @@ url='https://github.com/edx/edx-milestones', license='AGPL', classifiers=[ - 'Development Status :: 3 - Alpha', + 'Development Status :: 5 - Production/Stable', 'Environment :: Web Environment', 'Intended Audience :: Developers', 'License :: OSI Approved :: GNU Affero General Public License v3', 'Operating System :: OS Independent', 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', 'Framework :: Django', + 'Framework :: Django :: 1.11', ], packages=find_packages(exclude=["tests"]), install_requires=[ From 8fff540b407c4fae3dfb16c216f83f41ba97af83 Mon Sep 17 00:00:00 2001 From: Feanil Patel Date: Wed, 5 Jun 2019 14:54:17 -0400 Subject: [PATCH 11/11] Respond to review. --- manage.py | 3 +-- milestones/admin.py | 3 +-- milestones/api.py | 3 +-- milestones/data.py | 3 +-- milestones/exceptions.py | 3 +-- milestones/models.py | 29 +++++++++++++++++------------ milestones/serializers.py | 3 +-- milestones/services.py | 3 +-- milestones/tests/test_api.py | 3 +-- milestones/tests/test_data.py | 3 +-- milestones/tests/test_services.py | 3 +-- milestones/tests/utils.py | 3 +-- milestones/validators.py | 3 +-- setup.py | 3 +-- 14 files changed, 30 insertions(+), 38 deletions(-) diff --git a/manage.py b/manage.py index e979b3ff..91634b45 100755 --- a/manage.py +++ b/manage.py @@ -1,6 +1,5 @@ #!/usr/bin/env python -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import os import sys diff --git a/milestones/admin.py b/milestones/admin.py index 9e4eb04e..c97be9dd 100644 --- a/milestones/admin.py +++ b/milestones/admin.py @@ -1,8 +1,7 @@ """ Admin module for milestones app """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.contrib import admin from milestones.models import ( diff --git a/milestones/api.py b/milestones/api.py index a88bdbeb..c0f6e271 100644 --- a/milestones/api.py +++ b/milestones/api.py @@ -12,8 +12,7 @@ Note the terminology difference at this layer vs. Data -- add/edit/get/remove """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from . import data from . import exceptions from . import validators diff --git a/milestones/data.py b/milestones/data.py index c719117c..d6bec719 100644 --- a/milestones/data.py +++ b/milestones/data.py @@ -24,8 +24,7 @@ else: import milestones.resources as remote """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import six diff --git a/milestones/exceptions.py b/milestones/exceptions.py index cc8f3ee0..6bd44ea7 100644 --- a/milestones/exceptions.py +++ b/milestones/exceptions.py @@ -1,8 +1,7 @@ """ Application-specific exception classes used throughout the implementation """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.core.exceptions import ValidationError diff --git a/milestones/models.py b/milestones/models.py index 8d052f71..41a4f563 100644 --- a/milestones/models.py +++ b/milestones/models.py @@ -8,12 +8,13 @@ which leverages Django's signal framework. """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.db import models +from django.utils.encoding import python_2_unicode_compatible from model_utils.models import TimeStampedModel +@python_2_unicode_compatible class Milestone(TimeStampedModel): """ A Milestone is a representation of an accomplishment which can be @@ -33,10 +34,11 @@ class Meta: """ Meta class for this Django model """ unique_together = (("namespace", "name"),) - def __unicode__(self): - return str(self.namespace) + def __str__(self): + return self.namespace +@python_2_unicode_compatible class MilestoneRelationshipType(TimeStampedModel): """ A MilestoneRelationshipType represents a category of link available @@ -62,8 +64,8 @@ class MilestoneRelationshipType(TimeStampedModel): description = models.TextField(blank=True) active = models.BooleanField(default=True) - def __unicode__(self): - return str(self.name) + def __str__(self): + return self.name @classmethod # pylint: disable=invalid-name @@ -76,6 +78,7 @@ def get_supported_milestone_relationship_types(cls): return RELATIONSHIP_TYPE_CHOICES +@python_2_unicode_compatible class CourseMilestone(TimeStampedModel): """ A CourseMilestone represents the link between a Course and a @@ -95,10 +98,11 @@ class Meta: """ Meta class for this Django model """ unique_together = (("course_id", "milestone"),) - def __unicode__(self): - return str("%s:%s:%s" % (self.course_id, self.milestone_relationship_type, self.milestone)) + def __str__(self): + return "%s:%s:%s" % (self.course_id, self.milestone_relationship_type, self.milestone) +@python_2_unicode_compatible class CourseContentMilestone(TimeStampedModel): """ A CourseContentMilestone represents the link between a specific @@ -126,10 +130,11 @@ class Meta: """ Meta class for this Django model """ unique_together = (("course_id", "content_id", "milestone"),) - def __unicode__(self): - return str("%s:%s:%s" % (self.content_id, self.milestone_relationship_type, self.milestone)) + def __str__(self): + return "%s:%s:%s" % (self.content_id, self.milestone_relationship_type, self.milestone) +@python_2_unicode_compatible class UserMilestone(TimeStampedModel): """ A UserMilestone represents an stage reached or event experienced @@ -155,5 +160,5 @@ class Meta: """ Meta class for this Django model """ unique_together = ("user_id", "milestone") - def __unicode__(self): - return str("%s:%s" % (self.user_id, self.milestone)) + def __str__(self): + return "%s:%s" % (self.user_id, self.milestone) diff --git a/milestones/serializers.py b/milestones/serializers.py index 39cb67ca..a7396d3e 100644 --- a/milestones/serializers.py +++ b/milestones/serializers.py @@ -2,8 +2,7 @@ Data layer serialization operations. Converts querysets to simple python containers (mainly arrays and dicts). """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import json from . import models diff --git a/milestones/services.py b/milestones/services.py index 926a2ea1..717ad0fd 100644 --- a/milestones/services.py +++ b/milestones/services.py @@ -2,8 +2,7 @@ A wrapper class around requested methods exposed in api.py """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import types from milestones import api as milestones_api diff --git a/milestones/tests/test_api.py b/milestones/tests/test_api.py index e30abd48..83c219ab 100644 --- a/milestones/tests/test_api.py +++ b/milestones/tests/test_api.py @@ -4,8 +4,7 @@ """ Milestones API Module Test Cases """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from opaque_keys.edx.keys import UsageKey diff --git a/milestones/tests/test_data.py b/milestones/tests/test_data.py index b752f9f7..fd750f41 100644 --- a/milestones/tests/test_data.py +++ b/milestones/tests/test_data.py @@ -5,8 +5,7 @@ Note: 'Unit Test: ' labels are output to the console during test runs """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import milestones.api as api import milestones.data as data import milestones.exceptions as exceptions diff --git a/milestones/tests/test_services.py b/milestones/tests/test_services.py index af786aa0..87731bc2 100644 --- a/milestones/tests/test_services.py +++ b/milestones/tests/test_services.py @@ -2,8 +2,7 @@ Test for the xBlock service """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import unittest import types diff --git a/milestones/tests/utils.py b/milestones/tests/utils.py index a04de96a..ea93f915 100644 --- a/milestones/tests/utils.py +++ b/milestones/tests/utils.py @@ -2,8 +2,7 @@ """ Utility module for Milestones test cases """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from django.contrib.auth.models import User from django.test import TestCase from opaque_keys.edx.keys import CourseKey, UsageKey diff --git a/milestones/validators.py b/milestones/validators.py index ab36ee66..7c6ce2bb 100644 --- a/milestones/validators.py +++ b/milestones/validators.py @@ -1,8 +1,7 @@ """ Validators confirm the integrity of inbound information prior to a data.py handoff """ -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals import json import six diff --git a/setup.py b/setup.py index 727048d7..7f5002c8 100755 --- a/setup.py +++ b/setup.py @@ -1,7 +1,6 @@ #!/usr/bin/env python -from __future__ import absolute_import -from __future__ import unicode_literals +from __future__ import absolute_import, unicode_literals from setuptools import setup, find_packages from milestones import __version__ as VERSION