Ejemplo n.º 1
0
    def test_rest_endpoint_is_called(self):
        _mock_fetch_uris(self.endpoint, self.resource_uri)

        reader = APIReader(endpoint='http://' + self.endpoint, type='install',
                           field='foo')
        values = list(reader.extract(self.last_week, self.yesterday))

        # If we get back 20 values, it means that all the data had been read
        # from the API
        self.assertEquals(len(values), 20)
Ejemplo n.º 2
0
    def test_purge_raise_on_errors(self):
        HTTPretty.register_uri(
            HTTPretty.DELETE,
            re.compile(self.endpoint + ".*"),
            body="",
            status=400)
        reader = APIReader(endpoint='http://' + self.endpoint, type='install',
                           purge_data=True, field='foo')

        with self.assertRaises(HTTPError):
            reader.purge(self.last_week, self.now)
Ejemplo n.º 3
0
    def test_purge_calls_delete(self):
        HTTPretty.register_uri(
            HTTPretty.DELETE,
            re.compile(self.endpoint + ".*install.*"),
            body="",
            status=204)

        reader = APIReader(endpoint='http://' + self.endpoint, type='install',
                           purge_data=True, field='foo')
        reader.purge(self.last_week, self.now)
        self.assertEquals(HTTPretty.last_request.method, 'DELETE')
Ejemplo n.º 4
0
    def test_rest_endpoint_is_called(self):
        _mock_fetch_uris(self.endpoint, self.resource_uri)

        reader = APIReader(endpoint='http://' + self.endpoint,
                           type='install',
                           field='foo')
        values = list(reader.extract(self.last_week, self.yesterday))

        # If we get back 20 values, it means that all the data had been read
        # from the API
        self.assertEquals(len(values), 20)
Ejemplo n.º 5
0
    def test_purge_raise_on_errors(self):
        HTTPretty.register_uri(HTTPretty.DELETE,
                               re.compile(self.endpoint + ".*"),
                               body="",
                               status=400)
        reader = APIReader(endpoint='http://' + self.endpoint,
                           type='install',
                           purge_data=True,
                           field='foo')

        with self.assertRaises(HTTPError):
            reader.purge(self.last_week, self.now)
Ejemplo n.º 6
0
    def test_purge_calls_delete(self):
        HTTPretty.register_uri(HTTPretty.DELETE,
                               re.compile(self.endpoint + ".*install.*"),
                               body="",
                               status=204)

        reader = APIReader(endpoint='http://' + self.endpoint,
                           type='install',
                           purge_data=True,
                           field='foo')
        reader.purge(self.last_week, self.now)
        self.assertEquals(HTTPretty.last_request.method, 'DELETE')
Ejemplo n.º 7
0
 def test_get_id(self):
     reader = APIReader(id='mkt-install-foo',
                        endpoint='http://' + self.endpoint,
                        type='install', field='foo')
     self.assertEqual(reader.get_id(), 'mkt-install-foo')
Ejemplo n.º 8
0
 def test_get_id(self):
     reader = APIReader(id='mkt-install-foo',
                        endpoint='http://' + self.endpoint,
                        type='install',
                        field='foo')
     self.assertEqual(reader.get_id(), 'mkt-install-foo')