<s> """<STR_LIT>""" <EOL> from cafe . drivers . unittest . decorators import tags <EOL> from cloudcafe . blockstorage . volumes_api . v1 . models import statuses <EOL> from cloudcafe . common . tools . datagen import rand_name <EOL> from cloudcafe . compute . common . exceptions import ItemNotFound <EOL> from cloudroast . compute . fixtures import ServerFromVolumeV1Fixture <EOL> from cloudroast . compute . instance_actions . api . test_delete_server import DeleteServersTest <EOL> class AutoDeleteVolumeServersTest ( object ) : <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT>' ) <EOL> def test_volume_deleted_after_server_deletion_by_default ( self ) : <EOL> """<STR_LIT>""" <EOL> with self . assertRaises ( ItemNotFound ) : <EOL> self . blockstorage_behavior . client . delete_volume ( self . volume . id_ ) <EOL> class PersistentDeleteVolumeServersTest ( object ) : <EOL> @ tags ( type = '<STR_LIT>' , net = '<STR_LIT>' ) <EOL> def test_volume_not_deleted_after_server_deletion ( self ) : <EOL> """<STR_LIT>""" <EOL> self . blockstorage_behavior . wait_for_volume_status ( <EOL> self . volume . id_ , statuses . Volume . AVAILABLE , <EOL> self . volume_delete_timeout ) <EOL> server_response = self . server_behaviors . create_active_server ( <EOL> block_device_mapping = self . block_data , <EOL> flavor_ref = self . flavors_config . primary_flavor , <EOL> name = rand_name ( "<STR_LIT>" ) ) <EOL> server_sec = server_response . entity <EOL> self . servers_client . delete_server ( server_sec . id ) <EOL> self . server_behaviors . wait_for_server_to_be_deleted ( server_sec . id ) <EOL> result = self . blockstorage_behavior . client . delete_volume ( <EOL> self . volume . id_ ) <EOL> self . assertTrue ( result ) <EOL> class ServerFromVolumeV1AutoDeleteServerTests ( <EOL> ServerFromVolumeV1Fixture , <EOL> DeleteServersTest , <EOL> AutoDeleteVolumeServersTest ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( ServerFromVolumeV1AutoDeleteServerTests , cls ) . setUpClass ( ) <EOL> cls . create_server ( ) <EOL> cls . resp = cls . servers_client . delete_server ( cls . server . id ) <EOL> cls . server_behaviors . wait_for_server_to_be_deleted ( cls . server . id ) <EOL> class ServerFromVolumeV1PersistentDeleteServerTests ( <EOL> ServerFromVolumeV1Fixture , <EOL> PersistentDeleteVolumeServersTest ) : <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> """<STR_LIT>""" <EOL> super ( ServerFromVolumeV1PersistentDeleteServerTests , cls ) . setUpClass ( ) <EOL> cls . volume = cls . blockstorage_behavior . create_available_volume ( <EOL> size = cls . volume_size , <EOL> volume_type = cls . volume_type , <EOL> image_ref = cls . image_ref ) <EOL> cls . block_data = cls . server_behaviors . create_block_device_mapping_v1 ( <EOL> device_name = cls . images_config . primary_image_default_device , <EOL> size = cls . volume_size , volume_id = cls . volume . id_ , type = '<STR_LIT>' , <EOL> delete_on_termination = False ) <EOL> server_response = cls . server_behaviors . create_active_server ( <EOL> block_device_mapping = cls . block_data , <EOL> flavor_ref = cls . flavors_config . primary_flavor , <EOL> name = rand_name ( "<STR_LIT>" ) ) <EOL> server = server_response . entity <EOL> cls . servers_client . delete_server ( server . id ) <EOL> cls . server_behaviors . wait_for_server_to_be_deleted ( server . id ) </s>
