|
| 1 | +''' |
| 2 | +Tests in Pytest |
| 3 | +''' |
| 4 | +from app import app |
| 5 | + |
| 6 | + |
| 7 | +def test_client(): |
| 8 | + ''' |
| 9 | + Makes a request and checks the message received is the same |
| 10 | + ''' |
| 11 | + response = app.test_client().get('/test') |
| 12 | + assert response.status_code == 200 |
| 13 | + assert response.json['message'] == "Hello, World!" |
| 14 | + |
| 15 | + |
| 16 | +def test_experience(): |
| 17 | + ''' |
| 18 | + Add a new experience and then get all experiences. |
| 19 | + |
| 20 | + Check that it returns the new experience in that list |
| 21 | + ''' |
| 22 | + example_experience = { |
| 23 | + "title": "Software Developer", |
| 24 | + "company": "A Cooler Company", |
| 25 | + "start_date": "October 2022", |
| 26 | + "end_date": "Present", |
| 27 | + "description": "Writing JavaScript Code", |
| 28 | + "logo": "example-logo.png" |
| 29 | + } |
| 30 | + |
| 31 | + item_id = app.test_client().post('/resume/experience', |
| 32 | + json=example_experience).json['id'] |
| 33 | + response = app.test_client().get('/resume/experience') |
| 34 | + assert response.json[item_id] == example_experience |
| 35 | + |
| 36 | + |
| 37 | +def test_education(): |
| 38 | + ''' |
| 39 | + Add a new education and then get all educations. |
| 40 | + |
| 41 | + Check that it returns the new education in that list |
| 42 | + ''' |
| 43 | + example_education = { |
| 44 | + "course": "Engineering", |
| 45 | + "school": "NYU", |
| 46 | + "start_date": "October 2022", |
| 47 | + "end_date": "August 2024", |
| 48 | + "grade": "86%", |
| 49 | + "logo": "example-logo.png" |
| 50 | + } |
| 51 | + item_id = app.test_client().post('/resume/education', |
| 52 | + json=example_education).json['id'] |
| 53 | + |
| 54 | + response = app.test_client().get('/resume/education') |
| 55 | + assert response.json[item_id] == example_education |
| 56 | + |
| 57 | + |
| 58 | +def test_skill(): |
| 59 | + ''' |
| 60 | + Add a new skill and then get all skills. |
| 61 | + |
| 62 | + Check that it returns the new skill in that list |
| 63 | + ''' |
| 64 | + example_skill = { |
| 65 | + "name": "JavaScript", |
| 66 | + "proficiency": "2-4 years", |
| 67 | + "logo": "example-logo.png" |
| 68 | + } |
| 69 | + |
| 70 | + item_id = app.test_client().post('/resume/skill', |
| 71 | + json=example_skill).json['id'] |
| 72 | + |
| 73 | + response = app.test_client().get('/resume/skill') |
| 74 | + assert response.json[item_id] == example_skill |
0 commit comments