File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change 20
20
from google .api_core import exceptions
21
21
from google .cloud import servicedirectory_v1
22
22
23
+ import quickstart
23
24
import snippets
24
25
25
26
PROJECT_ID = environ ['GOOGLE_CLOUD_PROJECT' ]
34
35
def teardown_module ():
35
36
client = servicedirectory_v1 .RegistrationServiceClient ()
36
37
namespace_name = client .namespace_path (PROJECT_ID , LOCATION_ID , NAMESPACE_ID )
37
- try :
38
- namespace = client .get_namespace (name = namespace_name )
39
- client .delete_namespace (name = namespace .name )
40
- except exceptions .NotFound :
41
- pass
38
+ all_namespaces = quickstart .list_namespaces (PROJECT_ID , LOCATION_ID ).namespaces
39
+
40
+ # Delete namespace only if it exists
41
+ for namespace in all_namespaces :
42
+ if namespace_name in namespace .name :
43
+ try :
44
+ client .delete_namespace (name = namespace_name )
45
+ except exceptions .NotFound :
46
+ print ("Namespace already deleted" )
47
+ break
42
48
43
49
44
50
def test_create_namespace ():
You can’t perform that action at this time.
0 commit comments