Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add user journey test to retrieve a lockfile for a build #807

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading