Skip to content

Commit

Permalink
Add test for v2 api
Browse files Browse the repository at this point in the history
  • Loading branch information
shatakshiiii committed Oct 11, 2024
1 parent 5e6fab0 commit 897b171
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/ansible_dev_tools/resources/server/data/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ paths:
$ref: "#/components/schemas/Error"
/v1/creator/playbook:
post:
description: "Deprecated, please use the `/v2/creator/playbook` instead."
deprecated: true
summary: Create a new playbook project
requestBody:
content:
Expand Down
29 changes: 29 additions & 0 deletions tests/integration/test_server_creator.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,35 @@ def test_playbook_v1(server_url: str, tmp_path: Path) -> None:
)


def test_playbook_v2(server_url: str, tmp_path: Path) -> None:
"""Test the playbook creation.
Args:
server_url: The server URL.
tmp_path: Pytest tmp_path fixture.
"""
response = requests.post(
f"{server_url}/v2/creator/playbook",
json={
"project": "ansible-project",
"namespace": "ansible",
"collection_name": "devops",
},
timeout=10,
)
assert response.status_code == requests.codes.get("created")
assert response.headers["Content-Disposition"] == 'attachment; filename="ansible-devops.tar.gz"'
assert response.headers["Content-Type"] == "application/tar+gzip"
dest_file = tmp_path / "ansible-devops.tar.gz"
with dest_file.open(mode="wb") as tar_file:
tar_file.write(response.content)
with tarfile.open(dest_file) as file:
assert (
"./collections/ansible_collections/ansible/devops/roles/run/README.md"
in file.getnames()
)


def test_collection_v1(server_url: str, tmp_path: Path) -> None:
"""Test the collection creation.
Expand Down

0 comments on commit 897b171

Please sign in to comment.