-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check that recipe being used to fulfil a recipe exists.
- Loading branch information
Showing
3 changed files
with
137 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
EnvironmentInput, | ||
PackageInput, | ||
) | ||
from softpack_core.spack import Package | ||
from tests.integration.utils import builder_called_correctly | ||
|
||
pytestmark = pytest.mark.repo | ||
|
@@ -124,82 +125,125 @@ def test_request_recipe(httpx_post, testable_env_input): | |
|
||
httpx_post.assert_not_called() | ||
|
||
resp = client.post( | ||
url="/fulfilRequestedRecipe", | ||
json={ | ||
"name": "finalRecipe", | ||
"version": "1.2.1", | ||
"requestedName": "a_recipe", | ||
"requestedVersion": "1.2", | ||
}, | ||
app.spack.stored_packages.append( | ||
Package(name="finalRecipe", versions=["1.2.1"]) | ||
) | ||
|
||
assert resp.json() == {"message": "Recipe Fulfilled"} | ||
|
||
httpx_post.assert_called_once() | ||
|
||
env.name = "my_env-1" | ||
env.packages[1] = PackageInput.from_name("[email protected]") | ||
|
||
builder_called_correctly(httpx_post, env) | ||
|
||
envs = Environment.iter() | ||
|
||
assert len(envs) == 3 | ||
assert len(envs[0].packages) == 2 | ||
assert envs[0].packages[0].name == "pkg" | ||
assert envs[0].packages[0].version == "1" | ||
assert envs[0].packages[1].name == "finalRecipe" | ||
assert envs[0].packages[1].version == "1.2.1" | ||
|
||
resp = client.get(url="/requestedRecipes") | ||
|
||
assert resp.json() == [ | ||
{ | ||
"name": "b_recipe", | ||
"version": "1.4", | ||
"description": "Another description", | ||
"url": "http://example.com", | ||
"username": "me2", | ||
try: | ||
resp = client.post( | ||
url="/fulfilRequestedRecipe", | ||
json={ | ||
"name": "finalRecipe", | ||
"version": "1.2.1", | ||
"requestedName": "a_recipe", | ||
"requestedVersion": "1.2", | ||
}, | ||
) | ||
|
||
assert resp.json() == {"message": "Recipe Fulfilled"} | ||
|
||
httpx_post.assert_called_once() | ||
|
||
env.name = "my_env-1" | ||
env.packages[1] = PackageInput.from_name("[email protected]") | ||
|
||
builder_called_correctly(httpx_post, env) | ||
|
||
envs = Environment.iter() | ||
|
||
assert len(envs) == 3 | ||
assert len(envs[0].packages) == 2 | ||
assert envs[0].packages[0].name == "pkg" | ||
assert envs[0].packages[0].version == "1" | ||
assert envs[0].packages[1].name == "finalRecipe" | ||
assert envs[0].packages[1].version == "1.2.1" | ||
|
||
resp = client.get(url="/requestedRecipes") | ||
|
||
assert resp.json() == [ | ||
{ | ||
"name": "b_recipe", | ||
"version": "1.4", | ||
"description": "Another description", | ||
"url": "http://example.com", | ||
"username": "me2", | ||
} | ||
] | ||
|
||
resp = client.post( | ||
url="/removeRequestedRecipe", | ||
json={"name": "b_recipe", "version": "1.4"}, | ||
) | ||
|
||
assert resp.json() == {"message": "Request Removed"} | ||
|
||
resp = client.get(url="/requestedRecipes") | ||
|
||
assert resp.json() == [] | ||
|
||
resp = client.post( | ||
url="/requestRecipe", | ||
json={ | ||
"name": "c_recipe", | ||
"version": "0.9", | ||
"description": "Lorem ipsum.", | ||
"url": "http://example.com", | ||
"username": "me", | ||
}, | ||
) | ||
|
||
env = EnvironmentInput.from_path("users/me/my_env-2") | ||
env.packages = [ | ||
PackageInput.from_name("pkg@1"), | ||
PackageInput.from_name("*[email protected]"), | ||
] | ||
|
||
assert isinstance(Environment.create(env), CreateEnvironmentSuccess) | ||
|
||
resp = client.post( | ||
url="/removeRequestedRecipe", | ||
json={"name": "c_recipe", "version": "0.9"}, | ||
) | ||
|
||
assert resp.json() == { | ||
"error": "There are environments relying on this requested recipe;" | ||
+ " can not delete." | ||
} | ||
] | ||
|
||
resp = client.post( | ||
url="/removeRequestedRecipe", | ||
json={"name": "b_recipe", "version": "1.4"}, | ||
) | ||
|
||
assert resp.json() == {"message": "Request Removed"} | ||
|
||
resp = client.get(url="/requestedRecipes") | ||
|
||
assert resp.json() == [] | ||
|
||
resp = client.post( | ||
url="/requestRecipe", | ||
json={ | ||
"name": "c_recipe", | ||
"version": "0.9", | ||
"description": "Lorem ipsum.", | ||
"url": "http://example.com", | ||
"username": "me", | ||
}, | ||
) | ||
|
||
env = EnvironmentInput.from_path("users/me/my_env-2") | ||
env.packages = [ | ||
PackageInput.from_name("pkg@1"), | ||
PackageInput.from_name("*[email protected]"), | ||
] | ||
|
||
assert isinstance(Environment.create(env), CreateEnvironmentSuccess) | ||
|
||
resp = client.post( | ||
url="/removeRequestedRecipe", | ||
json={"name": "c_recipe", "version": "0.9"}, | ||
) | ||
|
||
assert resp.json() == { | ||
"error": "There are environments relying on this requested recipe; " | ||
+ "can not delete." | ||
} | ||
resp = client.post( | ||
url="/fulfilRequestedRecipe", | ||
json={ | ||
"name": "no_recipe", | ||
"version": "1", | ||
"requestedName": "c_recipe", | ||
"requestedVersion": "0.9", | ||
}, | ||
) | ||
|
||
assert resp.json() == {"error": "Unknown Recipe"} | ||
|
||
resp = client.post( | ||
url="/fulfilRequestedRecipe", | ||
json={ | ||
"name": "finalRecipe", | ||
"version": "1", | ||
"requestedName": "c_recipe", | ||
"requestedVersion": "0.9", | ||
}, | ||
) | ||
|
||
assert resp.json() == {"error": "Unknown Recipe"} | ||
|
||
resp = client.post( | ||
url="/fulfilRequestedRecipe", | ||
json={ | ||
"name": "finalRecipe", | ||
"version": "1.2.1", | ||
"requestedName": "c_recipe", | ||
"requestedVersion": "0.9", | ||
}, | ||
) | ||
|
||
assert resp.json() == {"message": "Recipe Fulfilled"} | ||
finally: | ||
app.spack.stored_packages.pop() |