<s> """<STR_LIT>""" <EOL> from collections import OrderedDict <EOL> from mock import MagicMock , Mock <EOL> from requests import Response <EOL> import sys <EOL> import unittest <EOL> from cafe . common . reporting import cclogging <EOL> from cafe . configurator . managers import _lazy_property <EOL> cclogging . init_root_log_handler ( ) <EOL> from cloudcafe . common . behaviors import StatusProgressionVerifierError <EOL> from cloudcafe . compute . volume_attachments_api . behaviors import VolumeAttachmentsAPI_Behaviors <EOL> from cloudcafe . compute . volume_attachments_api . client import VolumeAttachmentsAPIClient <EOL> from cloudcafe . compute . volume_attachments_api . config import VolumeAttachmentsAPIConfig <EOL> from cloudcafe . blockstorage . volumes_api . v2 . client import VolumesClient <EOL> from cloudcafe . blockstorage . volumes_api . v2 . models . responses import VolumeResponse <EOL> class MockBuilder ( object ) : <EOL> def _mock ( self , name , ** defaults ) : <EOL> defaults . update ( ** self . _overrides . get ( name , { } ) ) <EOL> setattr ( self , name , Mock ( ** defaults ) ) <EOL> class TestMocks ( MockBuilder ) : <EOL> def __init__ ( self , ** kwargs ) : <EOL> self . _overrides = kwargs <EOL> self . _mock ( <EOL> '<STR_LIT>' , spec = VolumeResponse , status = '<STR_LIT>' , id_ = '<STR_LIT>' ) <EOL> self . _mock ( <EOL> '<STR_LIT>' , spec = Response , ok = True , entity = self . volume_model ) <EOL> self . _mock ( <EOL> '<STR_LIT>' , spec = VolumesClient , <EOL> get_volume_info = MagicMock ( return_value = self . response ) ) <EOL> self . _mock ( <EOL> '<STR_LIT>' , spec = VolumeAttachmentsAPIClient ) <EOL> self . _mock ( <EOL> '<STR_LIT>' , spec = VolumeAttachmentsAPIConfig , <EOL> attachment_timeout = <NUM_LIT:1> , api_poll_rate = <NUM_LIT:1> ) <EOL> class BaseTestCase ( object ) : <EOL> mocks = TestMocks ( ) <EOL> def behavior_class_under_test ( self ) : <EOL> return VolumeAttachmentsAPI_Behaviors ( <EOL> self . mocks . volume_attachments_client , <EOL> self . mocks . volume_attachments_config , <EOL> self . mocks . volumes_client ) <EOL> def setUp ( self ) : <EOL> self . behaviors = self . behavior_class_under_test ( ) <EOL> class MethodTests_verify_volume_status_progression_during_attachment ( <EOL> BaseTestCase , unittest . TestCase ) : <EOL> def test_volume_is_attached ( self ) : <EOL> r = self . behaviors . verify_volume_status_progression_during_attachment ( <EOL> self . mocks . volume_model . id_ ) <EOL> class MethodTests_verify_volume_status_progression_during_detachment ( <EOL> BaseTestCase , unittest . TestCase ) : <EOL> mocks = TestMocks ( volume_model = dict ( status = '<STR_LIT>' ) ) <EOL> def test_volume_is_detached ( self ) : <EOL> r = self . behaviors . verify_volume_status_progression_during_detachment ( <EOL> self . mocks . volume_model . id_ ) </s>
