コード例 #1
0
ファイル: test_clients.py プロジェクト: mxr/nsq-py
 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'})
コード例 #2
0
ファイル: test_clients.py プロジェクト: mxr/nsq-py
 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={})
コード例 #3
0
ファイル: test_clients.py プロジェクト: mxr/nsq-py
    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
コード例 #4
0
ファイル: test_clients.py プロジェクト: mxr/nsq-py
 def test_tuple(self):
     '''Can create a client with a tuple'''
     http.BaseClient(('foo.com', 4161))
コード例 #5
0
ファイル: test_clients.py プロジェクト: mxr/nsq-py
 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')