pyfly-demo/tests/test_hov.py
Greg Gauthier 1e263f05ba fixes
2020-10-10 15:43:20 +01:00

40 lines
1.3 KiB
Python
Executable File

import os
from subprocess import Popen, PIPE
import requests
from hoverpy import capture
class TestUsingHoverpy:
root_url = "http://127.0.0.1:5000"
def teardown_class(self):
# deletes the captured sessions
os.remove("tests/test_version_call.db")
os.remove("tests/test_random_numbers.db")
os.remove("tests/test_random_string.db")
os.remove("tests/test_hashname.db")
@capture("tests/test_version_call.db", recordMode="once")
def test_version_call(self):
resp = requests.get(self.root_url + "/version")
assert resp.json()['version'] == 0.1
@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"