Example #1
0
 def test_plugins(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     plugins = Plugins()
     p1 = AnalysisPlugin({'name': 'AnalysisP1', 'version': 0, 'description': 'No'})
     plugins.plugins = [p1, ]
     with patch_requests('http://dummy/plugins', plugins):
         response = client.plugins()
         assert isinstance(response, dict)
         assert len(response) == 1
         assert "AnalysisP1" in response
Example #2
0
 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
Example #3
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
Example #4
0
 def test_plugins(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     plugins = Plugins()
     p1 = AnalysisPlugin({'name': 'AnalysisP1', 'version': 0, 'description': 'No'})
     plugins.plugins = [p1, ]
     with patch_requests(plugins) as (request, response):
         response = client.plugins()
         assert isinstance(response, dict)
         assert len(response) == 1
         assert "AnalysisP1" in response
     request.assert_called_with(
         url=endpoint + '/plugins', method='GET',
         params={})
Example #5
0
 def test_plugins(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     plugins = Plugins()
     p1 = AnalysisPlugin({'name': 'AnalysisP1', 'version': 0, 'description': 'No'})
     plugins.plugins = [p1, ]
     success = Call(plugins)
     with patch('requests.request', return_value=success) as patched:
         response = client.plugins()
         assert isinstance(response, dict)
         assert len(response) == 1
         assert "AnalysisP1" in response
     patched.assert_called_with(
         url=endpoint + '/plugins', method='GET',
         params={'plugin_type': default_plugin_type})
Example #6
0
 def test_plugins(self):
     endpoint = 'http://dummy/'
     client = Client(endpoint)
     plugins = Plugins()
     p1 = AnalysisPlugin({
         'name': 'AnalysisP1',
         'version': 0,
         'description': 'No'
     })
     plugins.plugins = [
         p1,
     ]
     with patch_requests('http://dummy/plugins', plugins):
         response = client.plugins()
         assert isinstance(response, dict)
         assert len(response) == 1
         assert "AnalysisP1" in response
Example #7
0
 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'})
Example #8
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'})
Example #9
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'})