2021-02-25 10:35:10 +00:00
|
|
|
import json
|
2021-02-25 13:41:02 +00:00
|
|
|
import pytest
|
|
|
|
from service.simple import app, hashit
|
2021-02-25 10:35:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
class TestSimple:
|
|
|
|
|
|
|
|
def setup(self):
|
|
|
|
self.app = app.test_client()
|
|
|
|
|
|
|
|
def teardown(self):
|
|
|
|
pass
|
|
|
|
|
|
|
|
def test_version(self):
|
|
|
|
resp = self.app.get('/version')
|
|
|
|
rjson = json.loads(resp.data)
|
|
|
|
assert rjson['version'] == 0.1
|
|
|
|
|
|
|
|
def test_random_numbers(self):
|
|
|
|
resp = self.app.get('/randoms')
|
|
|
|
rjson = json.loads(resp.data)
|
|
|
|
assert rjson['number'] <= 80
|
|
|
|
|
|
|
|
def test_random_string(self):
|
|
|
|
resp = self.app.get('/randoms')
|
|
|
|
rjson = json.loads(resp.data)
|
|
|
|
assert len(rjson['string']) <= 80
|
2021-02-25 13:41:02 +00:00
|
|
|
|
|
|
|
@pytest.mark.skip(reason="hash values diverge during unit testing")
|
|
|
|
def test_hashit(self):
|
|
|
|
test_name = "George"
|
|
|
|
test_hash = "-127751659231289515"
|
|
|
|
response = hashit(test_name)
|
|
|
|
response_hash = response["hash"]
|
|
|
|
assert response_hash == test_hash
|
|
|
|
|
|
|
|
|