Skip to content

Add missing test for DELETE /profile/{username} endpoint #11

@anxkhn

Description

@anxkhn

Context

The DELETE /profile/{username} endpoint exists in app/main.py but has no corresponding test in tests/test_profile.py. Every endpoint should have at least basic test coverage.

Steps to reproduce

  1. Run: pytest tests/test_profile.py -v
  2. Observe there is no test for the delete endpoint.
  3. Check tests/test_profile.py -- only test_create_profile, test_get_profile, and test_get_nonexistent_profile exist.

Expected behavior

There should be at least one test that verifies:

  • Deleting an existing profile returns 200 and {"deleted": true}
  • Deleting a non-existent profile returns 404

Actual behavior

No test exists for the DELETE /profile/{username} endpoint.

Files

  • tests/test_profile.py -- add new test function(s) here

Acceptance criteria

  • A test exists that creates a profile, deletes it, and verifies the response
  • A test exists that attempts to delete a non-existent profile and verifies 404
  • All tests pass: pytest tests/test_profile.py -v

Suggested approach

  1. Open tests/test_profile.py.
  2. Add a test function like:
    def test_delete_profile(clean_store):
        client.post("/profile", json={"username": "charlie", "bio": "tester"})
        response = client.delete("/profile/charlie")
        assert response.status_code == 200
        assert response.json() == {"deleted": True}
        # Verify it is actually gone
        get_response = client.get("/profile/charlie")
        assert get_response.status_code == 404
  3. Optionally add a test for deleting a non-existent profile.
  4. Run pytest tests/test_profile.py -v.

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueGood for newcomerstestsTest improvements or fixes

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions