generated from MLH-Fellowship/orientation-project-python
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_pytest.py
74 lines (59 loc) · 2.03 KB
/
test_pytest.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
74
'''
Tests in Pytest
'''
from app import app
def test_client():
'''
Makes a request and checks the message received is the same
'''
response = app.test_client().get('/test')
assert response.status_code == 200
assert response.json['message'] == "Hello, World!"
def test_experience():
'''
Add a new experience and then get all experiences.
Check that it returns the new experience in that list
'''
example_experience = {
"title": "Software Developer",
"company": "A Cooler Company",
"start_date": "October 2022",
"end_date": "Present",
"description": "Writing JavaScript Code",
"logo": "example-logo.png"
}
item_id = app.test_client().post('/resume/experience',
json=example_experience).json['id']
response = app.test_client().get('/resume/experience')
assert response.json[item_id] == example_experience
def test_education():
'''
Add a new education and then get all educations.
Check that it returns the new education in that list
'''
example_education = {
"course": "Engineering",
"school": "NYU",
"start_date": "October 2022",
"end_date": "August 2024",
"grade": "86%",
"logo": "example-logo.png"
}
item_id = app.test_client().post('/resume/education',
json=example_education).json['id']
response = app.test_client().get('/resume/education')
assert response.json[item_id] == example_education
def test_skill():
'''
Add a new skill and then get all skills.
Check that it returns the new skill in that list
'''
example_skill = {
"name": "JavaScript",
"proficiency": "2-4 years",
"logo": "example-logo.png"
}
item_id = app.test_client().post('/resume/skill',
json=example_skill).json['id']
response = app.test_client().get('/resume/skill')
assert response.json[item_id] == example_skill