Ejemplo n.º 1
0
 def test_params_post(self):
     '''Provides default parameters'''
     client = http.BaseClient('http://foo.com:1/', a='b')
     with mock.patch('nsq.http.requests') as MockClass:
         MockClass.post.return_value = mock.Mock(status_code=200,
                                                 content='{"foo": "bar"}')
         client.post('path')
         MockClass.post.assert_called_with('http://foo.com:1/path',
                                           params={'a': 'b'})
Ejemplo n.º 2
0
 def test_prefix_post(self):
     '''Posts to the appropriately-relativized path'''
     client = http.BaseClient('http://foo.com:1/prefix/')
     with mock.patch('nsq.http.requests') as MockClass:
         MockClass.post.return_value = mock.Mock(status_code=200,
                                                 content='{"foo": "bar"}')
         client.post('path')
         MockClass.post.assert_called_with('http://foo.com:1/prefix/path',
                                           params={})
Ejemplo n.º 3
0
    def setUp(self):
        self.result = mock.Mock()
        self.result.content = '{"foo": "bar"}'
        self.result.status_code = 200
        self.result.reason = 'OK'
        self.func = mock.Mock(return_value=self.result)
        self.client = http.BaseClient('http://foo:1')

        def function(*args, **kwargs):
            return self.func(*args, **kwargs)

        self.function = function
Ejemplo n.º 4
0
 def test_tuple(self):
     '''Can create a client with a tuple'''
     http.BaseClient(('foo.com', 4161))
Ejemplo n.º 5
0
 def test_string(self):
     '''Can make a client with a string'''
     # This test passes if no exception is thrown
     http.BaseClient('http://foo.com:4161')