import json import pytest from service.simple import app, hashit 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 @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