예제 #1
0
파일: test_client.py 프로젝트: TouK/vumi-go
    def test_request_no_auth(self):
        def stubbed_request(method, url, data, auth):
            self.assertEqual(auth, None)
            return FakeResponse(json.dumps({'data': {}}))

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

        client = DiamondashApiClient()
        client.request('put', 'foo', {}),
예제 #2
0
    def test_request_no_auth(self):
        def stubbed_request(method, url, data, auth):
            self.assertEqual(auth, None)
            return FakeResponse(json.dumps({'data': {}}))

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

        client = DiamondashApiClient()
        client.request('put', 'foo', {}),
예제 #3
0
파일: test_client.py 프로젝트: TouK/vumi-go
    def test_request(self):
        self.vumi_helper.patch_settings(
            DIAMONDASH_API_USERNAME='******',
            DIAMONDASH_API_PASSWORD='******')

        resp = FakeResponse(json.dumps({
            'success': True,
            'data': {'spam': 'ham'}
        }))

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

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

        client = DiamondashApiClient()
        self.assertEqual(
            client.request('put', 'foo', {'bar': 'baz'}),
            {'spam': 'ham'})
예제 #4
0
    def test_request(self):
        self.vumi_helper.patch_settings(DIAMONDASH_API_USERNAME='******',
                                        DIAMONDASH_API_PASSWORD='******')

        resp = FakeResponse(
            json.dumps({
                'success': True,
                'data': {
                    'spam': 'ham'
                }
            }))

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

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

        client = DiamondashApiClient()
        self.assertEqual(client.request('put', 'foo', {'bar': 'baz'}),
                         {'spam': 'ham'})