|
12 | 12 | from python_template.domain.entities.product import Product |
13 | 13 |
|
14 | 14 |
|
15 | | -@pytest.fixture |
16 | | -async def workflow() -> DiscontinueProductWorkflow: |
17 | | - return await DependencyContainer.get_discontinue_product_workflow() |
| 15 | +class TestDiscontinueProductWorkflow: |
| 16 | + @pytest.fixture |
| 17 | + async def workflow_fixture(self) -> DiscontinueProductWorkflow: |
| 18 | + return await DependencyContainer.get_discontinue_product_workflow() |
18 | 19 |
|
| 20 | + @pytest.fixture(autouse=True) |
| 21 | + def setup(self, workflow_fixture: DiscontinueProductWorkflow) -> None: |
| 22 | + self.workflow = workflow_fixture |
19 | 23 |
|
20 | | -class TestDiscontinueProductWorkflow: |
21 | | - async def test_discontinue_product( |
22 | | - self, workflow: DiscontinueProductWorkflow |
23 | | - ) -> None: |
| 24 | + async def test_discontinue_product(self) -> None: |
24 | 25 | cosmos_database = await DependencyContainer.get_cosmos_database() |
25 | 26 | product_container = cosmos_database.get_container_client(Product.__name__) |
26 | 27 | product = ProductBuilder().build() |
27 | 28 | await product_container.create_item(product.model_dump()) |
28 | 29 | request = DiscontinueProductRequest(id=product.id) |
29 | 30 |
|
30 | | - await workflow.execute(request) |
| 31 | + await self.workflow.execute(request) |
31 | 32 |
|
32 | | - async def test_fail_when_discontinuing_discontinued_product( |
33 | | - self, workflow: DiscontinueProductWorkflow |
34 | | - ) -> None: |
| 33 | + async def test_fail_when_discontinuing_discontinued_product(self) -> None: |
35 | 34 | cosmos_database = await DependencyContainer.get_cosmos_database() |
36 | 35 | product_container = cosmos_database.get_container_client(Product.__name__) |
37 | 36 | product = ProductBuilder().discontinued().build() |
38 | 37 | await product_container.create_item(product.model_dump()) |
39 | 38 | request = DiscontinueProductRequest(id=product.id) |
40 | 39 |
|
41 | 40 | with pytest.raises(ProductAlreadyDiscontinuedError): |
42 | | - await workflow.execute(request) |
| 41 | + await self.workflow.execute(request) |
0 commit comments