Skip to content

Commit

Permalink
Add user journey test for retrieving a lockfile for a build
Browse files Browse the repository at this point in the history
  • Loading branch information
peytondmurray committed Apr 3, 2024
1 parent 9f7b7e0 commit 66eadff
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
20 changes: 20 additions & 0 deletions conda-store-server/tests/user_journeys/test_user_journeys.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""User journey tests for the API."""

import json
import os

import pytest
Expand Down Expand Up @@ -170,3 +171,22 @@ def test_failed_build_logs(base_url: str):
"invalidpackagenamefaasdfagksdjfhgaskdf"
in api.get_logs(build_request["data"]["id"]).text
)


@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 = json.loads(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"])
18 changes: 17 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, Optional, Union
from typing import Any, Dict, Optional, Union

import requests
import utils.time_utils as time_utils
Expand Down Expand Up @@ -309,3 +310,18 @@ def get_environment(self, namespace: str, environment: str) -> dict[str, Any]:
return self._make_request(
f"api/v1/environment/{namespace}/{environment}/"
).json()["data"]

def get_lockfile(self, build_id: int) -> Dict[str, Any]:
"""Get a lockfile for the given build ID.
Parameters
----------
build_id : int
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)

0 comments on commit 66eadff

Please sign in to comment.