Beispiel #1
0
 def test_handle_with_no_matched_course_runs(self):
     DrupalPublishUuidConfigFactory(course_run_ids='NotARealCourseId')
     command = Command()
     with mock.patch('course_discovery.apps.course_metadata.publishers.'
                     'CourseRunMarketingSitePublisher.publish_obj'
                     ) as mock_publish_obj:
         command.handle()
         mock_publish_obj.assert_not_called()
Beispiel #2
0
 def test_handle_with_ids(self):
     DrupalPublishUuidConfigFactory(
         course_run_ids=','.join([self.course_run.key]))
     command = Command()
     with mock.patch('course_discovery.apps.course_metadata.publishers.'
                     'CourseRunMarketingSitePublisher.publish_obj'
                     ) as mock_publish_obj:
         command.handle()
         expected_calls = [mock.call(self.course_run, include_uuid=True)]
         mock_publish_obj.assert_has_calls(expected_calls)
Beispiel #3
0
    def test_handle_with_push_people(self):
        DrupalPublishUuidConfigFactory(
            course_run_ids='',
            push_people=True,
        )
        person = PersonFactory()
        command = Command()

        with mock.patch.object(MarketingSitePeople, 'update_person') as cm:
            command.handle()
        self.assertEqual(cm.call_count, 1)
        self.assertEqual(cm.call_args[0][0], person)
Beispiel #4
0
    def test_handle_with_push_people_error(self):
        DrupalPublishUuidConfigFactory(
            course_run_ids='',
            push_people=True,
        )
        PersonFactory()
        command = Command()

        # First test that a normal exception bubbles up like we expect
        with self.assertRaises(Exception):
            with mock.patch.object(MarketingSitePeople,
                                   'update_person',
                                   side_effect=Exception):
                command.handle()

        # Now tests that marketing exceptions don't stop us
        with mock.patch.object(
                MarketingSitePeople,
                'update_person',
                side_effect=MarketingSiteAPIClientException) as cm:
            command.handle()
            self.assertEqual(cm.call_count, 1)