예제 #1
0
    def test_items_count(self, get):
        get.side_effect = self._side_effect
        feeding_service = ntb_event_api.NTBEventsApiFeedingService()
        feeding_service.provider = PROVIDER
        items = feeding_service._update(PROVIDER, {})[0]

        self.assertEqual(len(items), 8)
예제 #2
0
    def test_items_count_ignore_duplicates(self, get):
        feeding_service = ntb_event_api.NTBEventsApiFeedingService()

        get.return_value.ok = True
        get.return_value.content = self.feeds[0]
        feeding_service.provider = PROVIDER
        items = feeding_service._update(PROVIDER, {})[0]
        self.assertEqual(len(items), 2)
예제 #3
0
    def test_requests_offset(self, get):
        get.side_effect = self._side_effect
        feeding_service = ntb_event_api.NTBEventsApiFeedingService()
        feeding_service.provider = PROVIDER
        feeding_service._update(PROVIDER, {})

        self.assertEqual(
            get.mock_calls[0],
            mock.call(PROVIDER['config']['url'],
                      auth=('fake', 'fake'),
                      params={
                          'search.offset': 0,
                          'search.showNumResults': 25
                      },
                      timeout=20))

        self.assertEqual(
            get.mock_calls[1],
            mock.call(PROVIDER['config']['url'],
                      auth=('fake', 'fake'),
                      params={
                          'search.offset': 2,
                          'search.showNumResults': 25
                      },
                      timeout=20))

        self.assertEqual(
            get.mock_calls[2],
            mock.call(PROVIDER['config']['url'],
                      auth=('fake', 'fake'),
                      params={
                          'search.offset': 4,
                          'search.showNumResults': 25
                      },
                      timeout=20))

        self.assertEqual(
            get.mock_calls[3],
            mock.call(PROVIDER['config']['url'],
                      auth=('fake', 'fake'),
                      params={
                          'search.offset': 6,
                          'search.showNumResults': 25
                      },
                      timeout=20))