-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest_root.py
73 lines (54 loc) · 1.93 KB
/
test_root.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
from flask import send_from_directory
import pytest
from app import create_app
@pytest.fixture()
def app():
''' creates app for testing '''
app = create_app()
app.config['TESTING'] = True
app.config['WTF_CSRF_ENABLED'] = False
# other setup can go here
yield app
@pytest.fixture()
def test_client(app):
''' creates client for testing '''
return app.test_client()
def test_home(client):
''' tests homepage '''
response = client.get("/")
assert response.status_code == 200
response = client.get("/home")
assert response.status_code == 200
def test_post_home(client):
''' tests homepage'''
response = client.post("/")
assert response.status_code == 405
def test_valid_file(client):
''' tests valid file input to form '''
file = 'test-tiny.tiff'
data = {'email': '[email protected]',
'file': (open(file, 'rb'), file), 'model': 'kevin_initial'}
response = client.get("/", data=data)
assert response.status_code == 200
def test_submit_form(client):
''' tests submitting of filled out form'''
file = 'test-tiny.tiff'
data = {'email': '[email protected]',
'file': (open(file, 'rb'), file), 'model': 'kevin_initial'}
response = client.post("/server", data=data)
assert response.status_code == 200
def test_submit_incomplete(client):
''' tests for submission of incomplete form'''
def test_invalid_file(client):
''' tests invalid file error '''
file = 'test-tiny.png'
data = {'email': '[email protected]',
'file': (open(file, 'rb'), file), 'model': 'kevin_initial'}
response = client.post("/server", data=data)
assert response.status_code == 200
assert file.encode() not in response.data
def test_model_status(client):
''' tests model status route returns successfully'''
response = client.get("/modelStatus")
assert response.status_code == 200
assert b"status" in response.data