<s> import mock <EOL> import testtools <EOL> from sahara import exceptions as ex <EOL> from sahara . service . validations import clusters as c_val <EOL> from sahara . tests . unit . service . validation import utils as u <EOL> from sahara . tests . unit import testutils as tu <EOL> class TestClusterDeleteValidation ( u . ValidationTestCase ) : <EOL> def setUp ( self ) : <EOL> super ( TestClusterDeleteValidation , self ) . setUp ( ) <EOL> self . setup_context ( tenant_id = '<STR_LIT>' ) <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_cluster_delete_when_protected ( self , get_cluster_p ) : <EOL> cluster = tu . create_cluster ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , [ '<STR_LIT>' ] , is_protected = True ) <EOL> get_cluster_p . return_value = cluster <EOL> with testtools . ExpectedException ( ex . DeletionFailed ) : <EOL> try : <EOL> c_val . check_cluster_delete ( cluster . id ) <EOL> except ex . DeletionFailed as e : <EOL> self . assert_protected_resource_exception ( e ) <EOL> raise e <EOL> @ mock . patch ( '<STR_LIT>' ) <EOL> def test_public_cluster_delete_from_another_tenant ( self , get_cluster_p ) : <EOL> cluster = tu . create_cluster ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , [ '<STR_LIT>' ] , is_public = True ) <EOL> get_cluster_p . return_value = cluster <EOL> with testtools . ExpectedException ( ex . DeletionFailed ) : <EOL> try : <EOL> c_val . check_cluster_delete ( cluster . id ) <EOL> except ex . DeletionFailed as e : <EOL> self . assert_created_in_another_tenant_exception ( e ) <EOL> raise e </s>
