@@ -55,6 +55,40 @@ def test_education():
5555 assert response .json [item_id ] == example_education
5656
5757
58+ def test_delete_education ():
59+ '''
60+ Add and delete an education entry by index.
61+
62+ Check that the entry is deleted successfully and the response is correct.
63+ '''
64+ example_education = {
65+ "course" : "Computer Science" ,
66+ "school" : "UBC" ,
67+ "start_date" : "January 2022" ,
68+ "end_date" : "June 2026" ,
69+ "grade" : "90%" ,
70+ "logo" : "example-logo.png"
71+ }
72+
73+ client = app .test_client ()
74+
75+ # Add new education:
76+ # TODO: Implement the '/resume/education' POST route in `app.py` before running this test. # pylint: disable=fixme
77+ post_resp = client .post ('/resume/education' , json = example_education )
78+ assert post_resp .status_code == 200
79+ item_id = post_resp .json ['id' ]
80+
81+ # Delete the education using the ID:
82+ del_resp = client .delete (f'/resume/education/{ item_id } ' )
83+ assert del_resp .status_code == 200
84+ assert del_resp .json ['message' ] == "Education has been deleted"
85+
86+ # Delete again to check if it fails:
87+ del_resp = client .delete (f'/resume/education/{ item_id } ' )
88+ assert del_resp .status_code == 404
89+ assert del_resp .json ['error' ] == "Index out of range"
90+
91+
5892def test_skill ():
5993 '''
6094 Add a new skill and then get all skills.
0 commit comments