Skip to content

Commit

Permalink
Add test to check for deleted_on field
Browse files Browse the repository at this point in the history
  • Loading branch information
soapy1 committed Jan 16, 2025
1 parent 9261a0d commit 6a40f7b
Showing 1 changed file with 25 additions and 7 deletions.
32 changes: 25 additions & 7 deletions conda-store-server/tests/_internal/server/views/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ def test_delete_build_unauth(testclient, seed_conda_store):
assert r.status == schema.APIStatus.ERROR


def test_delete_build_auth(testclient, seed_conda_store, authenticate, celery_worker):
def test_delete_build_auth_queued_build(testclient, seed_conda_store, authenticate, celery_worker):
build_id = 4

response = testclient.put(f"api/v1/build/{build_id}")
Expand All @@ -866,14 +866,32 @@ def test_delete_build_auth(testclient, seed_conda_store, authenticate, celery_wo
response = testclient.delete(f"api/v1/build/{new_build_id}")
assert response.status_code == 400

# r = schema.APIAckResponse.model_validate(response.json())
# assert r.status == schema.APIStatus.OK

# response = testclient.get(f'api/v1/build/{new_build_id}')
# assert response.status_code == 404
def test_delete_build_auth_completed_build(testclient, seed_conda_store, authenticate, celery_worker):
new_build_id = 4

# r = schema.APIResponse.model_validate(response.json())
# assert r.status == schema.APIStatus.ERROR
# ensure the build exists - seed_conda_store should create a build
# with id 4 that is in the "completed" state
response = testclient.get(f"api/v1/build/{new_build_id}")
response.raise_for_status()
response_json = response.json()
r = schema.APIGetBuild.model_validate(response_json)
assert r.status == schema.APIStatus.OK
build_data = response_json.get("data")
assert build_data.get("deleted_on") is None

# delete the build
response = testclient.delete(f"api/v1/build/{new_build_id}")
assert response.status_code == 200

# check to make sure the build has been deleted
response = testclient.get(f"api/v1/build/{new_build_id}")
response.raise_for_status()
response_json = response.json()
r = schema.APIGetBuild.model_validate(response_json)
assert r.status == schema.APIStatus.OK
build_data = response_json.get("data")
assert build_data.get("deleted_on") is not None


@pytest.mark.parametrize(
Expand Down

0 comments on commit 6a40f7b

Please sign in to comment.