11import pytest
22
33from modules .catalog .application .command import CreateListingDraftCommand
4- from seedwork .domain .value_objects import Money
4+ from seedwork .domain .value_objects import UUID , Money
55
66
77@pytest .mark .integration
@@ -18,7 +18,10 @@ def test_catalog_list_with_one_item(api, api_client):
1818 with catalog_module .unit_of_work ():
1919 command_result = catalog_module .execute_command (
2020 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" ),
2225 )
2326 )
2427
@@ -49,12 +52,18 @@ def test_catalog_list_with_two_items(api, api_client):
4952 with catalog_module .unit_of_work ():
5053 catalog_module .execute_command (
5154 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" ),
5359 )
5460 )
5561 catalog_module .execute_command (
5662 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" ),
5867 )
5968 )
6069
@@ -65,3 +74,28 @@ def test_catalog_list_with_two_items(api, api_client):
6574 assert response .status_code == 200
6675 response_data = response .json ()["data" ]
6776 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