コード例 #1
0
    def setUpTestData(cls):
        super().setUpTestData()
        cls.catalog_query_a = CatalogQueryFactory()
        cls.catalog_query_b = CatalogQueryFactory()
        cls.enterprise_catalog_a = EnterpriseCatalogFactory(
            catalog_query=cls.catalog_query_a)
        cls.enterprise_catalog_b = EnterpriseCatalogFactory(
            catalog_query=cls.catalog_query_b)

        ContentMetadataFactory.create_batch(3)
コード例 #2
0
 def setUp(self):
     super().setUp()
     self.set_up_staff()
     self.catalog_query = CatalogQueryFactory()
     self.enterprise_catalog = EnterpriseCatalogFactory(
         enterprise_uuid=self.enterprise_uuid,
         catalog_query=self.catalog_query,
     )
コード例 #3
0
    def test_get_metadata_by_query_with_error(self, mock_oauth_client):
        """
        get_metadata_by_query should return None when a call to discovery endpoint fails.
        """
        mock_oauth_client.return_value.post.side_effect = JSONDecodeError(
            'error', '{}', 0)

        catalog_query = CatalogQueryFactory()
        client = DiscoveryApiClient()
        with self.assertRaises(JSONDecodeError):
            client.get_metadata_by_query(catalog_query)

        mock_oauth_client.return_value.post.assert_called_once()
コード例 #4
0
    def test_get_metadata_by_query_with_error(self, mock_oauth_client):
        """
        get_metadata_by_query should return None when a call to discovery endpoint fails.
        """
        mock_oauth_client.return_value.post.side_effect = JSONDecodeError(
            'error', '{}', 0)

        catalog_query = CatalogQueryFactory()
        query_params = {'exclude_expired_course_run': True}
        client = DiscoveryApiClient()
        actual_response = client.get_metadata_by_query(catalog_query,
                                                       query_params)

        mock_oauth_client.return_value.post.assert_called_once()

        expected_response = None
        self.assertEqual(actual_response, expected_response)
コード例 #5
0
    def test_get_metadata_by_query_with_results(self, mock_oauth_client):
        """
        get_metadata_by_query should call discovery endpoint, but not call
        traverse_pagination if traverse_pagination is false.
        """
        mock_oauth_client.return_value.post.return_value.json.return_value = {
            'results': [{'key': 'fakeX'}],
        }

        catalog_query = CatalogQueryFactory()
        client = DiscoveryApiClient()
        actual_response = client.get_metadata_by_query(catalog_query)

        mock_oauth_client.return_value.post.assert_called_once()

        expected_response = [{'key': 'fakeX'}]
        self.assertEqual(actual_response, expected_response)
コード例 #6
0
    def test_update_content_metadata_for_filtered_queries(
            self, mock_full_metadata_task, mock_catalog_task, mock_chord):
        """
        Verify that the job creates an update task for every catalog query that is used by
        at least one enterprise catalog.
        """
        # Create another catalog query that isn't used by any catalog, so shouldn't be updated
        CatalogQueryFactory()

        call_command(self.command_name)

        mock_chord.assert_called_once_with([
            mock_catalog_task.s(catalog_query_id=self.catalog_query_a),
            mock_catalog_task.s(catalog_query_id=self.catalog_query_b),
        ])
        mock_full_metadata_task.si.assert_called_once_with(
            self._get_content_keys())
コード例 #7
0
ファイル: test_tasks.py プロジェクト: edx/enterprise-catalog
 def setUpTestData(cls):
     super().setUpTestData()
     cls.catalog_query = CatalogQueryFactory()