def test_multi_content_data_source_should_retrieve_content_for_each_of_the_supplied_ids(self):
     client = ContentIdRememberingStubClient()
     id_list = ['cat', 'spoon', 'mouse', 'dog']
     data_source = MultiContentDataSource(client=client, name='test_thing')
     data_source.content_ids = id_list
     data_source.fetch_data()
     self.assertEquals(set(client.content_ids), set(id_list))
Example #2
0
 def test_multi_content_data_source_should_retrieve_content_for_each_of_the_supplied_ids(
         self):
     client = ContentIdRememberingStubClient()
     id_list = ['cat', 'spoon', 'mouse', 'dog']
     data_source = MultiContentDataSource(client=client, name='test_thing')
     data_source.content_ids = id_list
     data_source.fetch_data()
     self.assertEquals(set(client.content_ids), set(id_list))
    def test_multi_content_data_source_should_return_data_in_correct_format(self):
        client = ContentIdRememberingStubClient()
        id_list = ['cat', 'spoon', 'mouse', 'dog']
        data_source = MultiContentDataSource(client=client, name='name')
        data_source.content_ids = id_list
        data = data_source.fetch_data()


        expected_content = {u'apiUrl': u'http://content.guardianapis.com/technology/gamesblog/2013/apr/09/press-start-game-news',
                            u'fields': {u'byline': u'Keith',
                                        u'commentable': u'true',
                                        u'headline': u'More stuff happened',
                                        u'liveBloggingNow': u'false',
                                        u'standfirst': u'Stand by your man',
                                        u'thumbnail': u'thumb piano',
                                        u'trailText': u'Stuff happened'},
                            u'id': u'content_1',
                            u'sectionId': u'cif',
                            u'sectionName': u'cif name',
                            u'webPublicationDate': u'2013-04-09T07:00:09Z',
                            u'webTitle': u'Toynbee speaks',
                            u'webUrl': u'http://www.theguardian.com/technology/gamesblog/2013/apr/09/press-start-game-news'}

        expected_data = []
        for i in range(4):
            expected_data.append(expected_content)
        self.assertEquals(expected_data, data)
Example #4
0
    def test_multi_content_data_source_should_return_data_in_correct_format(
            self):
        client = ContentIdRememberingStubClient()
        id_list = ['cat', 'spoon', 'mouse', 'dog']
        data_source = MultiContentDataSource(client=client, name='name')
        data_source.content_ids = id_list
        data = data_source.fetch_data()

        expected_content = {
            u'apiUrl':
            u'http://content.guardianapis.com/technology/gamesblog/2013/apr/09/press-start-game-news',
            u'fields': {
                u'byline': u'Keith',
                u'commentable': u'true',
                u'headline': u'More stuff happened',
                u'liveBloggingNow': u'false',
                u'standfirst': u'Stand by your man',
                u'thumbnail': u'thumb piano',
                u'trailText': u'Stuff happened'
            },
            u'id':
            u'content_1',
            u'sectionId':
            u'cif',
            u'sectionName':
            u'cif name',
            u'webPublicationDate':
            u'2013-04-09T07:00:09Z',
            u'webTitle':
            u'Toynbee speaks',
            u'webUrl':
            u'http://www.theguardian.com/technology/gamesblog/2013/apr/09/press-start-game-news'
        }

        expected_data = []
        for i in range(4):
            expected_data.append(expected_content)
        self.assertEquals(expected_data, data)
 def test_multi_content_data_source_should_barf_if_content_ids_is_left_unset(self):
     data_source = MultiContentDataSource('cheese_client', 'cheese_name')
     with self.assertRaises(DataSourceException):
         data_source.fetch_data()