'Test create snapshot.'

@mock.patch.object(qnap.QnapISCSIDriver, '_gen_random_name')
@mock.patch('cinder.volume.drivers.qnap.QnapAPIExecutor')
def test_create_snapshot_positive(self, mock_api_executor, mock_gen_random_name):

    fake_volume = VolumeClass('fakeDisplayName', 'fakeId', 100, 'fakeLunName')
    snapshot = SnapshotClass(fake_volume, 100)
    mock_api_executor.return_value.get_basic_info.return_value = ('ES1640dc    ', 'ES1640dc    ', '1.1.3')
    mock_api_executor.return_value.get_lun_info.return_value = self.get_lun_info_return_value()
    mock_gen_random_name.return_value = 'fakeSnapshot'
    mock_api_executor.return_value.get_snapshot_info.side_effect = [None, self.get_snapshot_info_return_value()]
    mock_api_executor.return_value.create_snapshot_api.return_value = 'fakeSnapshotId'
    self.driver = qnap.QnapISCSIDriver(configuration=create_configuration('admin', 'qnapadmin', 'http://1.2.3.4:8080', '1.2.3.4', 'Pool1', True))
    self.driver.do_setup('context')
    self.driver.create_snapshot(snapshot)
    mock_api_return = mock_api_executor.return_value
    mock_api_return.get_lun_info.assert_called_once_with(LUNNAA='fakeLunNaa')
    expected_call_list = [mock.call(lun_index='fakeLunIndex', snapshot_name='fakeSnapshot'), mock.call(lun_index='fakeLunIndex', snapshot_name='fakeSnapshot')]
    self.assertEqual(expected_call_list, mock_api_executor.return_value.get_snapshot_info.call_args_list)
    mock_api_return.create_snapshot_api.assert_called_once_with('fakeLunIndex', 'fakeSnapshot')
