Skip to content

Commit 0973140

Browse files
minor refactoring
1 parent 47a9236 commit 0973140

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests_integration/routers/test_customer.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import app.routers.customer as customer
1212
from app.model.customer import Customer
1313

14+
CUSTOMERS_ENDPOINT = "/context/customers"
15+
1416

1517
@pytest.fixture
1618
def reload_customer_router() -> None:
@@ -22,17 +24,17 @@ def test_customers_insert_read_delete(
2224
test_client: TestClient,
2325
reload_customer_router: None,
2426
):
25-
initial_delete_response: Response = test_client.delete("/context/customers")
27+
initial_delete_response: Response = test_client.delete(CUSTOMERS_ENDPOINT)
2628
assert_that(initial_delete_response.status_code).is_equal_to(204)
2729

2830
customer1 = Customer(first_name="fname1", last_name="lname1")
2931
customer2 = Customer(first_name="fname2", last_name="lname2")
3032
input_json = jsonable_encoder([customer1, customer2])
3133

32-
create_response: Response = test_client.put("/context/customers", json=input_json)
34+
create_response: Response = test_client.put(CUSTOMERS_ENDPOINT, json=input_json)
3335
assert_that(create_response.status_code).is_equal_to(204)
3436

35-
read_response: Response = test_client.get("/context/customers")
37+
read_response: Response = test_client.get(CUSTOMERS_ENDPOINT)
3638

3739
assert_that(read_response.status_code).is_equal_to(200)
3840
response_json: list[dict[str, Any]] = read_response.json()
@@ -41,10 +43,10 @@ def test_customers_insert_read_delete(
4143
assert_that(response_json).contains(jsonable_encoder(customer1))
4244
assert_that(response_json).contains(jsonable_encoder(customer2))
4345

44-
delete_response: Response = test_client.delete("/context/customers")
46+
delete_response: Response = test_client.delete(CUSTOMERS_ENDPOINT)
4547
assert_that(delete_response.status_code).is_equal_to(204)
4648

47-
read_response_after_delete: Response = test_client.get("/context/customers")
49+
read_response_after_delete: Response = test_client.get(CUSTOMERS_ENDPOINT)
4850

4951
assert_that(read_response_after_delete.status_code).is_equal_to(200)
5052
response_json_after_delete: list[dict[str, Any]] = read_response_after_delete.json()

tests_unit/routers/test_customer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010

1111
from app.model.customer import Customer
1212

13+
CUSTOMERS_ENDPOINT = "/context/customers"
14+
1315

1416
@pytest.fixture
1517
def mock_execute(mocker: MockerFixture) -> AsyncMock:
@@ -34,7 +36,7 @@ def mock_fetch_all(mocker: MockerFixture) -> AsyncMock:
3436

3537

3638
def test_customers_delete(mock_execute: AsyncMock, test_client: TestClient):
37-
response: Response = test_client.delete("/context/customers")
39+
response: Response = test_client.delete(CUSTOMERS_ENDPOINT)
3840
assert_that(response.status_code).is_equal_to(204)
3941

4042
assert len(mock_execute.call_args_list) == 1
@@ -46,7 +48,7 @@ def test_customers_insert(mock_execute_many: AsyncMock, test_client: TestClient)
4648
customer2 = Customer(first_name="fname2", last_name="lname2")
4749
input_json = jsonable_encoder([customer1, customer2])
4850

49-
response: Response = test_client.put("/context/customers", json=input_json)
51+
response: Response = test_client.put(CUSTOMERS_ENDPOINT, json=input_json)
5052
assert_that(response.status_code).is_equal_to(204)
5153

5254
assert len(mock_execute_many.call_args_list) == 1
@@ -65,7 +67,7 @@ def test_customers_read(mock_fetch_all: AsyncMock, test_client: TestClient):
6567

6668
mock_fetch_all.return_value = jsonable_encoder([customer1, customer2])
6769

68-
response: Response = test_client.get("/context/customers")
70+
response: Response = test_client.get(CUSTOMERS_ENDPOINT)
6971

7072
assert_that(response.status_code).is_equal_to(200)
7173
response_json: list[dict[str, Any]] = response.json()

0 commit comments

Comments
 (0)