Back to articles
Capstone Day 2: Testing the To-Do App API with Pytest

Capstone Day 2: Testing the To-Do App API with Pytest

via Dev.to WebdevFiyinfoluwa Ojo

Why Test the Capstone? Every feature I add could break an existing one. Automated tests catch that instantly. no manual Postman testing needed. 10 Tests Covering Everything Auth Tests Signup success Duplicate email returns 400 Login success returns accessToken Wrong password returns 401 Task Tests Create task returns 201 Get tasks returns data array Update task marks as completed Delete task returns 204 Get tasks without token returns 401 Create task without title returns 422 Key Test Pattern def get_token (): email = f " taskuser { int ( time . time ()) } @example.com " client . post ( " /auth/signup " , json = { " email " : email , " password " : " password123 " }) response = client . post ( " /auth/login " , json = { " email " : email , " password " : " password123 " }) return response . json ()[ " accessToken " ] Every task test creates its own user and token, tests are completely isolated from each other. Results 10 passed, 0 failed. ✅ Lessons Learned Testing a capstone project is

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
2 views

Related Articles