def options(self, **kwargs): """ Return an options dict that can be passed to self.command.handle() Passed in **kwargs will override existing defaults. Most defaults are the same as they are for running the management command manually (e.g. dry_run is False, show_receivers is False), except that the list of receivers is by default limited to the two that exist in this test class. We do this to keep these tests faster and more self contained. """ default_receivers = [ name_from_fn(self.sample_receiver_1), name_from_fn(self.sample_receiver_2), ] default_options = dict( show_receivers=False, dry_run=False, receivers=default_receivers, courses=None, delay=0, force_lms=False, skip_ccx=False, args_from_database=False ) default_options.update(kwargs) return default_options
def options(self, **kwargs): """ Return an options dict that can be passed to self.command.handle() Passed in **kwargs will override existing defaults. Most defaults are the same as they are for running the management command manually (e.g. dry_run is False, show_receivers is False), except that the list of receivers is by default limited to the two that exist in this test class. We do this to keep these tests faster and more self contained. """ default_receivers = [ name_from_fn(self.sample_receiver_1), name_from_fn(self.sample_receiver_2), ] default_options = dict( show_receivers=False, dry_run=False, receivers=default_receivers, courses=None, delay=0, force_lms=False, skip_ccx=False, ) default_options.update(kwargs) return default_options
def test_specific_receivers(self): """Test sending only to specific receivers.""" self.command.handle(**self.options( receivers=[name_from_fn(self.sample_receiver_1)])) assert self.course_key_1 in self.received_1 assert self.course_key_2 in self.received_1 assert self.course_key_3 in self.received_1 assert not self.received_2
def test_specific_receivers(self): """Test sending only to specific receivers.""" self.command.handle(**self.options( receivers=[name_from_fn(self.sample_receiver_1)])) self.assertIn(self.course_key_1, self.received_1) self.assertIn(self.course_key_2, self.received_1) self.assertIn(self.course_key_3, self.received_1) self.assertEqual(self.received_2, [])
def test_specific_receivers(self): """Test sending only to specific receivers.""" self.command.handle( **self.options( receivers=[name_from_fn(self.sample_receiver_1)] ) ) self.assertIn(self.course_key_1, self.received_1) self.assertIn(self.course_key_2, self.received_1) self.assertIn(self.course_key_3, self.received_1) self.assertEqual(self.received_2, [])
def test_course_overviews(self): """Integration test with CourseOverviews.""" assert CourseOverview.objects.all().count() == 0 # pylint: disable=protected-access self.command.handle(**self.options(receivers=[ name_from_fn(openedx.core.djangoapps.content.course_overviews. signals._listen_for_course_publish) ])) assert CourseOverview.objects.all().count() == 3 assert not self.received_1 assert not self.received_2
def test_course_overviews(self): """Integration test with CourseOverviews.""" self.assertEqual(CourseOverview.objects.all().count(), 0) # pylint: disable=protected-access self.command.handle( **self.options( receivers=[ name_from_fn(openedx.core.djangoapps.content.course_overviews.signals._listen_for_course_publish) ] ) ) self.assertEqual(CourseOverview.objects.all().count(), 3) self.assertEqual(self.received_1, []) self.assertEqual(self.received_2, [])