diff --git a/milestones/__init__.py b/milestones/__init__.py index 733bbf25..1e4f8241 100644 --- a/milestones/__init__.py +++ b/milestones/__init__.py @@ -1,4 +1,3 @@ """ Milestones app initialization module """ -from . import receivers diff --git a/milestones/data.py b/milestones/data.py index 02ce855b..9da11783 100644 --- a/milestones/data.py +++ b/milestones/data.py @@ -24,9 +24,9 @@ else: import milestones.resources as remote """ -import exceptions -import models as internal -import serializers +from . import exceptions +from . import models as internal +from . import serializers # PRIVATE/INTERNAL METHODS diff --git a/milestones/receivers.py b/milestones/receivers.py deleted file mode 100644 index bbea1764..00000000 --- a/milestones/receivers.py +++ /dev/null @@ -1,24 +0,0 @@ -""" -Receivers are listeners connected to the Django pub/sub signal -pipeline. When they observe a signal they run the decorated operation. - -In this particular application, the receivers simply hand-off to the -orchestration layer, which manages the application's workflows. -""" -from django.dispatch import receiver - -from . import api - -try: - from util import signals # pylint: disable=import-error -except ImportError: - from milestones.tests.mocks import signals - - -@receiver(signals.course_deleted) -def on_course_deleted(sender, signal, **kwargs): # pylint: disable=unused-argument - """ - Listens for a 'course_deleted' signal and when observed - hands off the event data to the MilestoneManager for processing - """ - api.remove_course_references(**kwargs) diff --git a/milestones/tests/mocks/signals.py b/milestones/tests/mocks/signals.py deleted file mode 100644 index 3d722764..00000000 --- a/milestones/tests/mocks/signals.py +++ /dev/null @@ -1,9 +0,0 @@ -# pylint: disable=invalid-name -""" -Mock signals module -- use these to trick Milestones into thinking the system -has broadcast a signal that it is listening for in receivers.py -""" -from django.dispatch import Signal - -# MOCK SIGNALS USED FOR STANDALONE TESTING -course_deleted = Signal(providing_args=["course_key"]) diff --git a/milestones/tests/test_receivers.py b/milestones/tests/test_receivers.py deleted file mode 100644 index 68b8599e..00000000 --- a/milestones/tests/test_receivers.py +++ /dev/null @@ -1,61 +0,0 @@ -# pylint: disable=too-many-public-methods -""" -Test Case Module for Milestones Signal Receivers -""" -from django.test import TestCase - -from opaque_keys.edx.keys import CourseKey - -import milestones.api as api - -from milestones.tests.mocks import signals as mock_signals - - -class ReceiverTestCase(TestCase): - """ - Main Test Suite for Milestones Signal Receivers - """ - - def setUp(self): - """ - Test Case scaffolding - """ - self.signal_log = [] - self.test_course_key = CourseKey.from_string('the/course/key') - self.test_prerequisite_course_key = CourseKey.from_string('prerequisite/course/key') - self.test_milestone_data = { - 'name': 'Test Milestone', - 'namespace': unicode(self.test_prerequisite_course_key), - 'description': 'This is only a test.', - } - - def test_on_course_deleted(self): - """ - Unit Test: test_on_course_deleted - Note, this test adds a milestone and two course links - We're going to confirm that all three entities are removed - """ - - # Add a new milestone and links to the system - milestone = api.add_milestone(milestone=self.test_milestone_data) - api.add_course_milestone( - course_key=self.test_course_key, - relationship='requires', - milestone=milestone - ) - api.add_course_milestone( - course_key=self.test_prerequisite_course_key, - relationship='fulfills', - milestone=milestone - ) - - # Inform the milestones app that the prerequisite course has - # now been removed from the system. - mock_signals.course_deleted.send( - sender=self, - course_key=self.test_prerequisite_course_key - ) - - # Confirm the course relationship no longer exists - prereq_milestones = api.get_course_milestones(course_key=self.test_prerequisite_course_key) - self.assertEqual(len(prereq_milestones), 0)