Skip to content

Commit

Permalink
tests for PUT changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shopiley committed Oct 7, 2024
1 parent fe6e394 commit b69ab91
Showing 1 changed file with 70 additions and 8 deletions.
78 changes: 70 additions & 8 deletions test_pytest.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,40 +59,86 @@ def test_experience():
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"
"data": [
{
"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

# test PUT request
response = app.test_client().put('/resume/experience', json={"data": [
{
"title": "Software Developer",
"company": "The Coolest Company",
"start_date": "October 2024",
"end_date": "Present",
"description": "Writing Python Code",
"logo": "example-logo.png"
}
]})
assert response.status_code == 200
response_data = response.json[0]
assert response_data['title'] == 'Software Developer'
assert response_data['company'] == 'The Coolest Company'
assert response_data['start_date'] == 'October 2024'
assert response_data['end_date'] == 'Present'
assert response_data['description'] == 'Writing Python Code'
assert response_data['logo'] == 'example-logo.png'


def test_education():
'''
Add a new education and then get all educations.
Check that it returns the new education in that list
'''
example_education = {
example_education = {"data": [{
"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

response = app.test_client().put('/resume/education', json={
"data": [
{
"course": "Updated Course",
"school": "Updated University",
"start_date": "September 2020",
"end_date": "June 2023",
"grade": "90%",
"logo": "new-education-logo.png"
}
]
})
assert response.status_code == 200
response_data = response.json[0]
assert response_data['course'] == 'Updated Course'
assert response_data['school'] == 'Updated University'
assert response_data['start_date'] == 'September 2020'
assert response_data['end_date'] == 'June 2023'
assert response_data['grade'] == '90%'
assert response_data['logo'] == 'new-education-logo.png'


def test_skill():
'''
Expand All @@ -111,3 +157,19 @@ def test_skill():

response = app.test_client().get('/resume/skill')
assert response.json[item_id] == example_skill

response = app.test_client().put('/resume/skill', json={
"data": [
{
"name": "Python",
"proficiency": "4-6 years",
"logo": "new-logo.png"
}
]
})
assert response.status_code == 200
response_data = response.json[0]
assert response_data['name'] == 'Python'
assert response_data['proficiency'] == '4-6 years'
assert response_data['logo'] == 'new-logo.png'

0 comments on commit b69ab91

Please sign in to comment.