Beispiel #1
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
Beispiel #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
Beispiel #3
0
 def test_patch_dict(self):
     r = {'nothing': 'new'}
     with patch_requests(ENDPOINT, r):
         res = requests.get(ENDPOINT)
         assert res.text == json.dumps(r)
         js = res.json()
         assert js
         assert js['nothing'] == 'new'
Beispiel #4
0
 def test_patch_json(self):
     r = Results()
     with patch_requests(ENDPOINT, r):
         res = requests.get(ENDPOINT)
         assert res.text == json.dumps(r.jsonld())
         js = res.json()
         assert js
         assert js['@type'] == r['@type']
Beispiel #5
0
 def test_patch_dict(self):
     r = {'nothing': 'new'}
     with patch_requests(ENDPOINT, r):
         res = requests.get(ENDPOINT)
         assert res.text == json.dumps(r)
         js = res.json()
         assert js
         assert js['nothing'] == 'new'
Beispiel #6
0
 def test_patch_json(self):
     r = Results()
     with patch_requests(ENDPOINT, r):
         res = requests.get(ENDPOINT)
         assert res.text == json.dumps(r.jsonld())
         js = res.json()
         assert js
         assert js['@type'] == r['@type']
Beispiel #7
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
Beispiel #8
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
Beispiel #9
0
 def test_patch_text(self):
     with patch_requests(ENDPOINT, 'hello'):
         r = requests.get(ENDPOINT)
         assert r.text == 'hello'
Beispiel #10
0
 def test_patch_text(self):
     with patch_requests(ENDPOINT, 'hello'):
         r = requests.get(ENDPOINT)
         assert r.text == 'hello'