1717
1818import stream
1919from stream import serializer
20- from stream .exceptions import ApiKeyException , InputException
20+ from stream .exceptions import ApiKeyException , InputException , DoesNotExistException
2121from stream .feed import Feed
2222
2323
@@ -150,14 +150,14 @@ def test_api_url(self):
150150 )
151151
152152 def test_collections_url_default (self ):
153- c = stream .connect ("key" , "secret" )
153+ c = stream .connect ("key" , "secret" , location = "" )
154154 feed_url = c .get_full_url (relative_url = "meta/" , service_name = "api" )
155155
156156 if not self .local_tests :
157157 self .assertEqual (feed_url , "https://api.stream-io-api.com/api/v1.0/meta/" )
158158
159159 def test_personalization_url_default (self ):
160- c = stream .connect ("key" , "secret" )
160+ c = stream .connect ("key" , "secret" , location = "" )
161161 feed_url = c .get_full_url (
162162 relative_url = "recommended" , service_name = "personalization"
163163 )
@@ -169,7 +169,7 @@ def test_personalization_url_default(self):
169169 )
170170
171171 def test_api_url_default (self ):
172- c = stream .connect ("key" , "secret" )
172+ c = stream .connect ("key" , "secret" , location = "" )
173173 feed_url = c .get_full_url (service_name = "api" , relative_url = "feed/" )
174174
175175 if not self .local_tests :
@@ -1439,6 +1439,37 @@ def test_reaction_delete(self):
14391439 )
14401440 self .c .reactions .delete (response ["id" ])
14411441
1442+ def test_reaction_hard_delete (self ):
1443+ response = self .c .reactions .add (
1444+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1445+ )
1446+ self .c .reactions .delete (response ["id" ], soft = False )
1447+
1448+ def test_reaction_soft_delete (self ):
1449+ response = self .c .reactions .add (
1450+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1451+ )
1452+ self .c .reactions .delete (response ["id" ], soft = True )
1453+
1454+ def test_reaction_soft_delete_and_restore (self ):
1455+ response = self .c .reactions .add (
1456+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1457+ )
1458+ self .c .reactions .delete (response ["id" ], soft = True )
1459+ r1 = self .c .reactions .get (response ["id" ])
1460+ self .assertIsNot (r1 ["deleted_at" ], None )
1461+ self .c .reactions .restore (response ["id" ])
1462+ r1 = self .c .reactions .get (response ["id" ])
1463+ self .assertTrue ("deleted_at" not in r1 )
1464+
1465+ def test_reaction_invalid_restore (self ):
1466+ response = self .c .reactions .add (
1467+ "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
1468+ )
1469+ self .assertRaises (
1470+ DoesNotExistException , lambda : self .c .reactions .restore (response ["id" ])
1471+ )
1472+
14421473 def test_reaction_add_child (self ):
14431474 response = self .c .reactions .add (
14441475 "like" , "54a60c1e-4ee3-494b-a1e3-50c06acb5ed4" , "mike"
0 commit comments