def test_get_snapshot_info_es(self): """Test get snapsho info api.""" mock_http_connection = six.moves.http_client.HTTPConnection mock_http_connection.return_value.getresponse.side_effect = [ fakes.FakeLoginResponse(), fakes.FakeGetBasicInfoResponseEs_1_1_3(), fakes.FakeLoginResponse(), fakes.FakeSnapshotInfoResponse() ] self._do_setup('http://1.2.3.4:8080', '1.2.3.4', 'admin', 'qnapadmin', 'Storage Pool 1') self.driver.api_executor.get_snapshot_info( volID='volId', snapshot_name='fakeSnapshotName') fake_params = { 'func': 'extra_get', 'volumeID': 'volId', 'snapshot_list': '1', 'snap_start': '0', 'snap_count': '100', 'sid': 'fakeSid', } sanitized_params = self._sanitize_params(fake_params) fake_url = ('/cgi-bin/disk/snapshot.cgi?%s' % sanitized_params) expected_call_list = [ mock.call('GET', self.login_url), mock.call('GET', self.get_basic_info_url), mock.call('GET', self.login_url), mock.call('GET', fake_url) ] self.assertEqual( expected_call_list, mock_http_connection.return_value.request.call_args_list)
def test_get_snapshot_info_ts_api(self): """Test get snapshot info api.""" mock_http_connection = six.moves.http_client.HTTPConnection mock_http_connection.return_value.getresponse.side_effect = [ fakes.FakeLoginResponse(), fakes.FakeGetBasicInfoResponseTs_4_3_0(), fakes.FakeLoginResponse(), fakes.FakeSnapshotInfoResponse() ] self._do_setup('http://1.2.3.4:8080', '1.2.3.4', 'admin', 'qnapadmin', 'Storage Pool 1') self.driver.api_executor.get_snapshot_info( snapshot_name='fakeSnapshotName', lun_index='fakeLunIndex') fake_params = { 'func': 'extra_get', 'LUNIndex': 'fakeLunIndex', 'smb_snapshot_list': '1', 'smb_snapshot': '1', 'snapshot_list': '1', 'sid': 'fakeSid' } sanitized_params = self._sanitize_params(fake_params) fake_url = (('/cgi-bin/disk/snapshot.cgi?%s') % sanitized_params) expected_call_list = [ mock.call('GET', self.login_url), mock.call('GET', self.get_basic_info_url), mock.call('GET', self.login_url), mock.call('GET', fake_url) ] self.assertEqual( expected_call_list, mock_http_connection.return_value.request.call_args_list)