<s> import uuid <EOL> from openstack . block_store . v2 import snapshot as _snapshot <EOL> from openstack . block_store . v2 import volume as _volume <EOL> from openstack . tests . functional import base <EOL> class TestSnapshot ( base . BaseFunctionalTest ) : <EOL> SNAPSHOT_NAME = uuid . uuid4 ( ) . hex <EOL> SNAPSHOT_ID = None <EOL> VOLUME_NAME = uuid . uuid4 ( ) . hex <EOL> VOLUME_ID = None <EOL> @ classmethod <EOL> def setUpClass ( cls ) : <EOL> super ( TestSnapshot , cls ) . setUpClass ( ) <EOL> volume = cls . conn . block_store . create_volume ( <EOL> name = cls . VOLUME_NAME , <EOL> size = <NUM_LIT:1> ) <EOL> cls . conn . block_store . wait_for_status ( volume , <EOL> status = '<STR_LIT>' , <EOL> failures = [ '<STR_LIT:error>' ] , <EOL> interval = <NUM_LIT:2> , <EOL> wait = <NUM_LIT> ) <EOL> assert isinstance ( volume , _volume . Volume ) <EOL> cls . assertIs ( cls . VOLUME_NAME , volume . name ) <EOL> cls . VOLUME_ID = volume . id <EOL> snapshot = cls . conn . block_store . create_snapshot ( <EOL> name = cls . SNAPSHOT_NAME , <EOL> volume_id = cls . VOLUME_ID ) <EOL> cls . conn . block_store . wait_for_status ( snapshot , <EOL> status = '<STR_LIT>' , <EOL> failures = [ '<STR_LIT:error>' ] , <EOL> interval = <NUM_LIT:2> , <EOL> wait = <NUM_LIT> ) <EOL> assert isinstance ( snapshot , _snapshot . Snapshot ) <EOL> cls . assertIs ( cls . SNAPSHOT_NAME , snapshot . name ) <EOL> cls . SNAPSHOT_ID = snapshot . id <EOL> @ classmethod <EOL> def tearDownClass ( cls ) : <EOL> snapshot = cls . conn . block_store . get_snapshot ( cls . SNAPSHOT_ID ) <EOL> sot = cls . conn . block_store . delete_snapshot ( snapshot , <EOL> ignore_missing = False ) <EOL> cls . conn . block_store . wait_for_delete ( snapshot , <EOL> interval = <NUM_LIT:2> , <EOL> wait = <NUM_LIT> ) <EOL> cls . assertIs ( None , sot ) <EOL> sot = cls . conn . block_store . delete_volume ( cls . VOLUME_ID , <EOL> ignore_missing = False ) <EOL> cls . assertIs ( None , sot ) <EOL> def test_get ( self ) : <EOL> sot = self . conn . block_store . get_snapshot ( self . SNAPSHOT_ID ) <EOL> self . assertEqual ( self . SNAPSHOT_NAME , sot . name ) </s>
