Skip to content

Commit

Permalink
fix: usr: Fix data sent to snapshot/restore_point API
Browse files Browse the repository at this point in the history
  • Loading branch information
Adesh Rao authored and Rohit Agarwal committed Jun 17, 2015
1 parent 8473701 commit c827521
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions qds_sdk/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,6 @@ def _parse_snapshot_restore_command(cls, args, action):
help="back_id from which restoration will be done", required=True)
argparser.add_argument("--table_names",
help="table(s) which are to be restored", required=True)

argparser.add_argument("--no-overwrite", action="store_false",
help="With this option, restore overwrites to the existing table if theres any in restore target")
argparser.add_argument("--no-automatic", action="store_false",
Expand Down Expand Up @@ -520,6 +519,7 @@ def _parse_update_snapshot_schedule(cls, args):
help="s3_location about where to store snapshots")
argparser.add_argument("--status",
help="status of periodic job you want to change to", choices = ["RUNNING", "SUSPENDED"])

arguments = argparser.parse_args(args)

return arguments
Expand All @@ -534,7 +534,7 @@ def snapshot(cls, cluster_id_label, s3_location, backup_type):
parameters['s3_location'] = s3_location
if backup_type:
parameters['backup_type'] = backup_type
return conn.post(cls.element_path(cluster_id_label) + "/snapshot", data={"parameters" : parameters})
return conn.post(cls.element_path(cluster_id_label) + "/snapshot", data=parameters)

@classmethod
def restore_point(cls, cluster_id_label, s3_location, backup_id, table_names, overwrite=True, automatic=True):
Expand All @@ -548,7 +548,7 @@ def restore_point(cls, cluster_id_label, s3_location, backup_id, table_names, ov
parameters['table_names'] = table_names
parameters['overwrite'] = overwrite
parameters['automatic'] = automatic
return conn.post(cls.element_path(cluster_id_label) + "/restore_point", data={"parameters" : parameters})
return conn.post(cls.element_path(cluster_id_label) + "/restore_point", data=parameters)

@classmethod
def get_snapshot_schedule(cls, cluster_id_label):
Expand Down
12 changes: 6 additions & 6 deletions tests/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ def test_snapshot(self):
print_command()
Connection._api_call = Mock(return_value={})
qds.main()
Connection._api_call.assert_called_with('POST', 'clusters/1234/snapshot', {'parameters': {'s3_location':'myString', 'backup_type':'full'}})
Connection._api_call.assert_called_with('POST', 'clusters/1234/snapshot', {'s3_location':'myString', 'backup_type':'full'})

def test_snapshot_with_no_label(self):
sys.argv = ['qds.py', 'cluster', 'snapshot', '--s3_location', 'myString', '--backup_type', 'full']
Expand All @@ -1595,35 +1595,35 @@ def test_snapshot_with_no_backup_type(self):
print_command()
Connection._api_call = Mock(return_value={})
qds.main()
Connection._api_call.assert_called_with('POST', 'clusters/1234/snapshot', {'parameters': {'s3_location':'myString'}})
Connection._api_call.assert_called_with('POST', 'clusters/1234/snapshot', {'s3_location':'myString'})

def test_restore_point(self):
sys.argv = ['qds.py', 'cluster', 'restore_point', '--label', '1234', '--s3_location', 'myString', '--backup_id', 'abcd', '--table_names', 'tablename']
print_command()
Connection._api_call = Mock(return_value={})
qds.main()
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'parameters': {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': True, 'overwrite': True}})
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': True, 'overwrite': True})

def test_restore_point_no_overwrite(self):
sys.argv = ['qds.py', 'cluster', 'restore_point', '--label', '1234', '--s3_location', 'myString', '--backup_id', 'abcd', '--table_names', 'tablename', '--no-overwrite']
print_command()
Connection._api_call = Mock(return_value={})
qds.main()
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'parameters': {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': True, 'overwrite': False}})
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': True, 'overwrite': False})

def test_restore_point_no_automatic(self):
sys.argv = ['qds.py', 'cluster', 'restore_point', '--label', '1234', '--s3_location', 'myString', '--backup_id', 'abcd', '--table_names', 'tablename', '--no-automatic']
print_command()
Connection._api_call = Mock(return_value={})
qds.main()
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'parameters': {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': False, 'overwrite': True}})
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': False, 'overwrite': True})

def test_restore_point_no_overwrite_and_no_automatic(self):
sys.argv = ['qds.py', 'cluster', 'restore_point', '--label', '1234', '--s3_location', 'myString', '--backup_id', 'abcd', '--table_names', 'tablename', '--no-overwrite', '--no-automatic']
print_command()
Connection._api_call = Mock(return_value={})
qds.main()
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'parameters': {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': False, 'overwrite': False}})
Connection._api_call.assert_called_with('POST', 'clusters/1234/restore_point', {'s3_location':'myString', 'backup_id':'abcd', 'table_names':'tablename', 'automatic': False, 'overwrite': False})

def test_restore_point_with_no_label(self):
sys.argv = ['qds.py', 'cluster', 'restore_point', '--s3_location', 'myString', '--backup_id', 'abcd', '--table_names', 'tablename']
Expand Down

0 comments on commit c827521

Please sign in to comment.