pyfly-demo/tests/test_hov.py

40 lines
1.3 KiB
Python
Raw Normal View History

2019-05-23 09:28:51 +00:00
import os
from subprocess import Popen, PIPE
import requests
from hoverpy import capture
class TestUsingHoverpy:
2019-05-23 12:19:43 +00:00
root_url = "http://127.0.0.1:5000"
2019-05-23 09:28:51 +00:00
def teardown_class(self):
2019-05-23 12:19:43 +00:00
# deletes the captured sessions
2019-05-23 09:28:51 +00:00
os.remove("tests/test_version_call.db")
2019-05-23 12:19:43 +00:00
os.remove("tests/test_random_numbers.db")
os.remove("tests/test_random_string.db")
os.remove("tests/test_hashname.db")
2019-05-23 09:28:51 +00:00
@capture("tests/test_version_call.db", recordMode="once")
def test_version_call(self):
2019-05-23 12:19:43 +00:00
resp = requests.get(self.root_url + "/version")
2019-05-23 09:28:51 +00:00
assert resp.json()['version'] == 0.1
2019-05-23 12:19:43 +00:00
@capture("tests/test_random_numbers.db", recordMode="once")
def test_random_numbers(self):
resp = requests.get(self.root_url + "/randoms")
assert resp.json()['number'] <= 80
@capture("tests/test_random_string.db", recordMode="once")
def test_random_string(self):
resp = requests.get(self.root_url + "/randoms")
assert len(resp.json()['string']) <= 80
@capture("tests/test_hashname.db", recordMode="once")
def test_hashname(self):
req_body = {
"name": "Frootloops Johnson"
}
resp = requests.post(self.root_url + "/hashname", json=req_body)
assert resp.json()['name'] == "Frootloops Johnson"