File tree Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Expand file tree Collapse file tree 3 files changed +28
-2
lines changed Original file line number Diff line number Diff line change 88
99Features:
1010
11+ * Add a `wait ` argument to `Model.delete_table ` (:pr: `1270 `)
1112* Add the ability to set or unset the boto retry configuration (:pr: `1271 `)
1213
1314 * This adds the ability to directly set the boto retry configuration dictionary, or
Original file line number Diff line number Diff line change @@ -760,11 +760,18 @@ def exists(cls: Type[_T]) -> bool:
760760 return False
761761
762762 @classmethod
763- def delete_table (cls ) -> Any :
763+ def delete_table (cls , * , wait : bool = False ) -> Any :
764764 """
765765 Delete the table for this model
766+
767+ :param wait: If set, then this call will block until the table is deleted
766768 """
767- return cls ._get_connection ().delete_table ()
769+ result = cls ._get_connection ().delete_table ()
770+
771+ while wait and cls .exists ():
772+ time .sleep (2 )
773+
774+ return result
768775
769776 @classmethod
770777 def describe_table (cls ) -> Any :
Original file line number Diff line number Diff line change @@ -3438,3 +3438,21 @@ def test_delete(add_version_condition: bool) -> None:
34383438 }
34393439 args = req .call_args [0 ][1 ]
34403440 assert args == expected
3441+
3442+ def test_delete_with_wait (mocker ):
3443+ """Test that the wait argument works as expected on the delete."""
3444+ mock_exists = mocker .patch .object (target = Model , attribute = "exists" , autospec = True )
3445+ mock__get_connection = mocker .patch .object (
3446+ target = Model , attribute = "_get_connection" , autospec = True
3447+ )
3448+
3449+ # Make the first two exists calls show the table as still existing, then have the
3450+ # last call show it has been deleted.
3451+ mock_exists .side_effect = (True , True , False )
3452+
3453+ result = Model .delete_table (wait = True )
3454+
3455+ # Should have returned the delete value.
3456+ assert result == mock__get_connection .return_value .delete_table .return_value
3457+ # Should have called exists 3 times.
3458+ assert mock_exists .call_count == 3
You can’t perform that action at this time.
0 commit comments