Exemple #1
0
    def test_raw_request_no_auth(self):
        def stubbed_request(method, url, data, auth):
            self.assertEqual(auth, None)
            return FakeResponse()

        self.monkey_patch(requests, 'request', stubbed_request)

        client = DiamondashApiClient()
        client.raw_request('put', 'foo'),
Exemple #2
0
    def test_raw_request_no_auth(self):
        def stubbed_request(method, url, data, auth):
            self.assertEqual(auth, None)
            return FakeResponse()

        self.monkey_patch(requests, 'request', stubbed_request)

        client = DiamondashApiClient()
        client.raw_request('put', 'foo'),
Exemple #3
0
    def test_raw_request(self):
        self.vumi_helper.patch_settings(DIAMONDASH_API_USERNAME='******',
                                        DIAMONDASH_API_PASSWORD='******')

        resp = FakeResponse('spam', 201)

        def stubbed_request(method, url, data, auth):
            self.assertEqual(method, 'put')
            self.assertEqual(url, 'http://diamondash.moc/api/foo')
            self.assertEqual(data, 'bar')
            self.assertEqual(auth, ('username', 'password'))
            return resp

        self.monkey_patch(requests, 'request', stubbed_request)

        client = DiamondashApiClient()
        self.assertEqual(client.raw_request('put', 'foo', 'bar'), {
            'code': 201,
            'content': 'spam'
        })
Exemple #4
0
    def test_raw_request(self):
        self.vumi_helper.patch_settings(
            DIAMONDASH_API_USERNAME='******',
            DIAMONDASH_API_PASSWORD='******')

        resp = FakeResponse('spam', 201)

        def stubbed_request(method, url, data, auth):
            self.assertEqual(method, 'put')
            self.assertEqual(url, 'http://diamondash.moc/api/foo')
            self.assertEqual(data, 'bar')
            self.assertEqual(auth, ('username', 'password'))
            return resp

        self.monkey_patch(requests, 'request', stubbed_request)

        client = DiamondashApiClient()
        self.assertEqual(client.raw_request('put', 'foo', 'bar'), {
            'code': 201,
            'content': 'spam'
        })