コード例 #1
0
ファイル: test_client.py プロジェクト: gsi-upm/senpy
 def test_client_post(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     with patch_requests('http://dummy/', Results()):
         resp = client.analyse('hello')
         assert isinstance(resp, Results)
     with patch_requests('http://dummy/', Error('Nothing'), method='POST'):
         try:
             client.analyse(input='hello', method='POST', algorithm='NONEXISTENT')
             raise Exception('Exceptions should be raised. This is not golang')
         except Error:
             pass
コード例 #2
0
 def test_client(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     with patch_requests('http://dummy/', Results()):
         resp = client.analyse('hello')
         assert isinstance(resp, Results)
     with patch_requests('http://dummy/', Error('Nothing')):
         try:
             client.analyse(input='hello', algorithm='NONEXISTENT')
             raise Exception(
                 'Exceptions should be raised. This is not golang')
         except Error:
             pass
コード例 #3
0
ファイル: test_client.py プロジェクト: jiixing/senpy
 def test_client(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     with patch_requests(Results()) as (request, response):
         resp = client.analyse('hello')
         assert isinstance(resp, Results)
     request.assert_called_with(
         url=endpoint + '/', method='GET', params={'input': 'hello'})
     with patch_requests(Error('Nothing')) as (request, response):
         try:
             client.analyse(input='hello', algorithm='NONEXISTENT')
             raise Exception('Exceptions should be raised. This is not golang')
         except Error:
             pass
     request.assert_called_with(
         url=endpoint + '/',
         method='GET',
         params={'input': 'hello',
                 'algorithm': 'NONEXISTENT'})
コード例 #4
0
 def test_client(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     success = Call(Results())
     with patch('requests.request', return_value=success) as patched:
         resp = client.analyse('hello')
         assert isinstance(resp, Results)
     patched.assert_called_with(
         url=endpoint + '/', method='GET', params={'input': 'hello'})
     error = Call(Error('Nothing'))
     with patch('requests.request', return_value=error) as patched:
         try:
             client.analyse(input='hello', algorithm='NONEXISTENT')
             raise Exception('Exceptions should be raised. This is not golang')
         except Error:
             pass
     patched.assert_called_with(
         url=endpoint + '/',
         method='GET',
         params={'input': 'hello',
                 'algorithm': 'NONEXISTENT'})
コード例 #5
0
ファイル: test_client.py プロジェクト: MixedEmotions/senpy
 def test_client(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     success = Call(Results())
     with patch('requests.request', return_value=success) as patched:
         resp = client.analyse('hello')
         assert isinstance(resp, Results)
     patched.assert_called_with(
         url=endpoint + '/', method='GET', params={'input': 'hello'})
     error = Call(Error('Nothing'))
     with patch('requests.request', return_value=error) as patched:
         try:
             client.analyse(input='hello', algorithm='NONEXISTENT')
             raise Exception('Exceptions should be raised. This is not golang')
         except Error:
             pass
     patched.assert_called_with(
         url=endpoint + '/',
         method='GET',
         params={'input': 'hello',
                 'algorithm': 'NONEXISTENT'})