@@ -63,8 +63,9 @@ def __enter__(self):
6363 def __exit__ (self , type , value , traceback ):
6464 # Delete the policy and channel we created.
6565 self .alert_policy_client .delete_alert_policy (self .alert_policy .name )
66- self .notification_channel_client .delete_notification_channel (
67- self .notification_channel .name )
66+ if self .notification_channel .name :
67+ self .notification_channel_client .delete_notification_channel (
68+ self .notification_channel .name )
6869
6970
7071@pytest .fixture (scope = 'session' )
@@ -114,3 +115,12 @@ def test_backup_and_restore(capsys, pochan):
114115 assert "Updated {0}" .format (pochan .alert_policy .name ) in out
115116 assert "Updating channel {0}" .format (
116117 pochan .notification_channel .display_name ) in out
118+
119+
120+ def test_delete_channels (capsys , pochan ):
121+ notification_channel_id = pochan .notification_channel .name .split ('/' )[- 1 ]
122+ snippets .delete_notification_channels (
123+ pochan .project_name , [notification_channel_id ], force = True )
124+ out , _ = capsys .readouterr ()
125+ assert "{0} deleted" .format (notification_channel_id ) in out
126+ pochan .notification_channel .name = '' # So teardown is not tried
0 commit comments