'Test volume attachment and detach.'

@mock.patch.object(requests, 'request', FakeRequests)
def test_volume_attach_detach(self):

    volume = {'name': 'test_volume_01', 'size': 1, 'id': 123}
    connector = dict(initiator='test_iqn.1')
    self.driver.create_volume(volume)
    props = self.driver.initialize_connection(volume, connector)
    self.assertEqual('iser', props['driver_volume_type'])
    data = props['data']
    self.assertEqual('1.1.1.1:3260', data['target_portal'])
    self.assertEqual('iqn.2011-04.com.zadarastorage:vsa-xxx:1', data['target_iqn'])
    self.assertEqual(int('0'), data['target_lun'])
    self.assertEqual(123, data['volume_id'])
    self.assertEqual('CHAP', data['auth_method'])
    self.assertEqual('test_chap_user', data['auth_username'])
    self.assertEqual('test_chap_secret', data['auth_password'])
    self.driver.terminate_connection(volume, connector)
    self.driver.delete_volume(volume)
