Skip to content

Commit

Permalink
Added user journey test to delete old environment
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Mar 15, 2024
1 parent fe6b45a commit 10a818f
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
29 changes: 29 additions & 0 deletions conda-store-server/tests/user_journeys/test_user_journeys.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,3 +100,32 @@ def test_user_login_and_create_shared_environment(

api.delete_environment(namespace, environment)
api.delete_namespace(namespace)


@pytest.mark.user_journey
def test_admin_delete_environment(base_url: str):
"""Test that an admin can delete environments."""
specs = [
"tests/user_journeys/test_data/simple_environment.yaml"
]
api = utils.API(base_url=base_url)

# Create a shared namespace; default permissions for namepace/environment
# */* is admin
namespace = api.create_namespace().json()["data"]["name"]

envs = []
for spec in specs:
envs.append(
api.create_environment(
namespace, spec
).json()["data"]["specification"]["name"]
)

assert len(api.list_environments(namespace).json()["data"]) == len(specs)

for env in envs:
api.delete_environment(namespace, env)

assert len(api.list_environments(namespace).json()["data"]) == 0
api.delete_namespace(namespace)
7 changes: 7 additions & 0 deletions conda-store-server/tests/user_journeys/utils/api_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ def delete_environment(
f"api/v1/environment/{namespace}/{environment_name}", method="DELETE"
)

def list_environments(
self, namespace: str
):
return self._make_request(
f"api/v1/environment/?namespace={namespace}", method="GET"
)

def delete_namespace(self, namespace: str) -> requests.Response:
"""Delete a namespace."""
return self._make_request(f"api/v1/namespace/{namespace}", method="DELETE")
Expand Down

0 comments on commit 10a818f

Please sign in to comment.