@@ -116,23 +116,29 @@ def test_delete_product(self, create_authenticated_headers, create_product):
116116 assert get_resp .status_code == 404
117117 self ._verify_product_in_db ("ToDelete" , should_exist = False )
118118
119- def test_get_product_by_name (self , create_product ):
120- product_name = "Test Product With Spaces"
121- response = create_product (product_name , "A test product with spaces" )
119+ @pytest .mark .parametrize (
120+ "name" ,
121+ [
122+ "Test Product With Spaces And / And @" ,
123+ "Café" ,
124+ "C++" ,
125+ "20% off"
126+ ]
127+ )
128+ def test_get_product_by_name (self , create_product , name ):
129+ response = create_product (name , "desc" )
122130 assert response .status_code == 201
123131 data = response .get_json ()
124132 p_id = data ["id" ]
125133
126- encoded_name = quote (product_name )
127- get_resp = self .client .get (f"/product/{ encoded_name } " )
134+ get_resp = self .client .get ("/product" , query_string = {"name" : name })
128135 assert get_resp .status_code == 200
129136 prod_data = get_resp .get_json ()
130137 assert prod_data ["id" ] == p_id
131- assert prod_data ["name" ] == product_name
132- assert prod_data ["description" ] == "A test product with spaces "
138+ assert prod_data ["name" ] == name
139+ assert prod_data ["description" ] == "desc "
133140
134- encoded_name = quote ("Non Existent Product" )
135- not_found_resp = self .client .get (f"/product/{ encoded_name } " )
141+ not_found_resp = self .client .get ("/product" , query_string = {"name" : "Non existent product" })
136142 assert not_found_resp .status_code == 404
137143
138144 @pytest .mark .parametrize (
0 commit comments