Skip to content

Commit

Permalink
test: convert first unit test for queues to using new client
Browse files Browse the repository at this point in the history
  • Loading branch information
jkglasbrenner committed Aug 30, 2024
1 parent 37671b7 commit d58c11f
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions tests/unit/restapi/v1/test_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from flask_sqlalchemy import SQLAlchemy
from werkzeug.test import TestResponse

from dioptra.client.client import DioptraClient
from dioptra.restapi.routes import V1_ENTRYPOINTS_ROUTE, V1_QUEUES_ROUTE, V1_ROOT

from ..lib import actions, asserts, helpers
Expand Down Expand Up @@ -147,7 +148,7 @@ def assert_queue_response_contents_matches_expectations(


def assert_retrieving_queue_by_id_works(
client: FlaskClient,
dioptra_client: DioptraClient,
queue_id: int,
expected: dict[str, Any],
) -> None:
Expand All @@ -162,10 +163,8 @@ def assert_retrieving_queue_by_id_works(
AssertionError: If the response status code is not 200 or if the API response
does not match the expected response.
"""
response = client.get(
f"/{V1_ROOT}/{V1_QUEUES_ROUTE}/{queue_id}", follow_redirects=True
)
assert response.status_code == 200 and response.get_json() == expected
response = dioptra_client.queues.get_by_id(queue_id)
assert response.status_code == 200 and response.json() == expected


def assert_retrieving_queues_works(
Expand Down Expand Up @@ -323,7 +322,7 @@ def assert_cannot_rename_queue_with_existing_name(


def test_create_queue(
client: FlaskClient,
dioptra_client: DioptraClient,
db: SQLAlchemy,
auth_account: dict[str, Any],
) -> None:
Expand All @@ -339,10 +338,10 @@ def test_create_queue(
description = "The first queue."
user_id = auth_account["id"]
group_id = auth_account["groups"][0]["id"]
queue1_response = actions.register_queue(
client, name=name, description=description, group_id=group_id
queue1_response = dioptra_client.queues.create(
group=group_id, name=name, description=description
)
queue1_expected = queue1_response.get_json()
queue1_expected = queue1_response.json()
assert_queue_response_contents_matches_expectations(
response=queue1_expected,
expected_contents={
Expand All @@ -353,7 +352,7 @@ def test_create_queue(
},
)
assert_retrieving_queue_by_id_works(
client, queue_id=queue1_expected["id"], expected=queue1_expected
dioptra_client, queue_id=queue1_expected["id"], expected=queue1_expected
)


Expand Down

0 comments on commit d58c11f

Please sign in to comment.