Skip to content

Commit

Permalink
Add user journey test to retrieve a lockfile for a build (#807)
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray authored Apr 22, 2024
1 parent 71a5632 commit 524a1cc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
19 changes: 19 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 @@ -207,3 +207,22 @@ def check_status():
return status == utils.BuildStatus.CANCELED

utils.wait_for_condition(check_status, timeout=60, interval=1)


@pytest.mark.user_journey
def test_get_lockfile(base_url: str):
"""Test that an admin can access a valid lockfile for a build."""
api = utils.API(base_url=base_url)
namespace = "default"
build_request = api.create_environment(
namespace,
"tests/user_journeys/test_data/simple_environment.yaml",
).json()

lockfile = api.get_lockfile(build_request["data"]["id"])

packages = set(package["name"] for package in lockfile["package"])
assert "python" in packages
assert "fastapi" in packages

api.delete_environment(namespace, build_request["data"]["specification"]["name"])
14 changes: 13 additions & 1 deletion conda-store-server/tests/user_journeys/utils/api_utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"""Helper functions for user journeys."""

import json
import time
import uuid

from enum import Enum
from typing import Any, Callable, Optional, Union
from typing import Any, Callable, Dict, Optional, Union

import requests
import utils.time_utils as time_utils
Expand Down Expand Up @@ -325,6 +326,17 @@ def get_build_status(self, build_id: int) -> BuildStatus:
response = self._make_request(f"api/v1/build/{build_id}/")
return BuildStatus(response.json()["data"]["status"])

def get_lockfile(self, build_id: int) -> Dict[str, Any]:
"""Get a lockfile for the given build ID.
Build for which the lockfile is to be retrieved
Returns
-------
Dict[str, Any]
Dictionary containing the lockfile version, metadata, and packages
"""
return json.loads(self._make_request(f"api/v1/build/{build_id}/lockfile").text)


def wait_for_condition(
condition: Callable[[], bool], timeout: int = 60, interval: int = 1
Expand Down

0 comments on commit 524a1cc

Please sign in to comment.