1
1
import pytest
2
2
3
3
from modules .catalog .application .command import CreateListingDraftCommand
4
- from seedwork .domain .value_objects import Money
4
+ from seedwork .domain .value_objects import UUID , Money
5
5
6
6
7
7
@pytest .mark .integration
@@ -18,7 +18,10 @@ def test_catalog_list_with_one_item(api, api_client):
18
18
with catalog_module .unit_of_work ():
19
19
command_result = catalog_module .execute_command (
20
20
CreateListingDraftCommand (
21
- title = "Foo" , description = "Bar" , ask_price = Money (10 ), seller_id = "abcd"
21
+ title = "Foo" ,
22
+ description = "Bar" ,
23
+ ask_price = Money (10 ),
24
+ seller_id = UUID ("00000000000000000000000000000002" ),
22
25
)
23
26
)
24
27
@@ -49,12 +52,18 @@ def test_catalog_list_with_two_items(api, api_client):
49
52
with catalog_module .unit_of_work ():
50
53
catalog_module .execute_command (
51
54
CreateListingDraftCommand (
52
- title = "Foo #1" , description = "Bar" , ask_price = Money (10 ), seller_id = "abcd"
55
+ title = "Foo #1" ,
56
+ description = "Bar" ,
57
+ ask_price = Money (10 ),
58
+ seller_id = UUID ("00000000000000000000000000000002" ),
53
59
)
54
60
)
55
61
catalog_module .execute_command (
56
62
CreateListingDraftCommand (
57
- title = "Foo #2" , description = "Bar" , ask_price = Money (10 ), seller_id = "abcd"
63
+ title = "Foo #2" ,
64
+ description = "Bar" ,
65
+ ask_price = Money (10 ),
66
+ seller_id = UUID ("00000000000000000000000000000002" ),
58
67
)
59
68
)
60
69
@@ -65,3 +74,28 @@ def test_catalog_list_with_two_items(api, api_client):
65
74
assert response .status_code == 200
66
75
response_data = response .json ()["data" ]
67
76
assert len (response_data ) == 2
77
+
78
+
79
+ @pytest .mark .integration
80
+ def test_catalog_delete_draft (api , api_client ):
81
+ catalog_module = api .container .catalog_module ()
82
+ with catalog_module .unit_of_work ():
83
+ result = catalog_module .execute_command (
84
+ CreateListingDraftCommand (
85
+ title = "Foo to be deleted" ,
86
+ description = "Bar" ,
87
+ ask_price = Money (10 ),
88
+ seller_id = UUID ("00000000000000000000000000000002" ),
89
+ )
90
+ )
91
+
92
+ response = api_client .delete (f"/catalog/{ result .entity_id } " )
93
+
94
+ assert response .status_code == 204
95
+
96
+
97
+ @pytest .mark .integration
98
+ def test_catalog_delete_non_existing_draft_returns_404 (api , api_client ):
99
+ listing_id = UUID ("00000000000000000000000000000001" )
100
+ response = api_client .delete (f"/catalog/{ listing_id } " )
101
+ assert response .status_code == 404
0 commit comments