def test_duplicate(self): sys.argv = ['qds.py', 'group', 'duplicate', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "POST", "groups/123/duplicate", {})
def test_delete_group(self): sys.argv = ['qds.py', 'group', 'delete', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "DELETE", "groups/123", None)
def test_remove_roles(self): sys.argv = ['qds.py', 'group', 'remove-roles', '123', '456,789'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "PUT", "groups/123", {'removed_roles': '456,789'})
def test_list(self): sys.argv = ['qds.py', 'group', 'list'] print_command() Connection._api_call = Mock(return_value={'groups': []}) qds.main() Connection._api_call.assert_called_with( "GET", "groups", params=None)
def test_results(self): sys.argv = ['qds.py', 'action', 'results', '123'] print_command() Connection._api_call = Mock() Connection._api_call.side_effect = common_side_effect qds.main() Connection._api_call.assert_has_calls([call("GET", "actions/123", params=None),call("GET", "commands/123/results", params={'inline': True})])
def test_minimal(self): sys.argv = ['qds.py', 'report', 'canonical_hive_commands'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("GET", "reports/canonical_hive_commands", params={})
def test_remove_users(self): sys.argv = ['qds.py', 'group', 'remove-users', '123', '456,789'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( 'PUT', 'groups/123', {'removed_members': '456,789'})
def test_duplicate(self): sys.argv = ['qds.py', 'role', 'duplicate', '123'] print_command() Connection._api_call = Mock(return_value={'roles':[]}) qds.main() Connection._api_call.assert_has_calls(call("POST", "roles/123/duplicate", params=None))
def test_list_groups(self): sys.argv = ['qds.py', 'role', 'list_groups', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_has_calls(call("GET", "roles/123/groups", params=None))
def test_unassign_role(self): sys.argv = ['qds.py', 'role', 'unassign_role', '123', "--group_id", "456"] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_has_calls(call("PUT", "roles/123/groups/456/unassign", params=None))
def test_by_user(self): sys.argv = ['qds.py', 'report', 'all_commands', '--by-user'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "GET", "reports/all_commands", params={'by_user': True})
def test_update(self): sys.argv = ['qds.py', 'role', 'update', '123', '--name', 'test'] print_command() Connection._api_call = Mock(return_value={'roles':[]}) qds.main() Connection._api_call.assert_has_calls(call("PUT", "roles/123", params={'name':'test'}))
def test_limit(self): sys.argv = ['qds.py', 'report', 'all_commands', '--limit', '20'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "GET", "reports/all_commands", params={'limit': 20})
def test_sort_cpu(self): sys.argv = ['qds.py', 'report', 'all_commands', '--sort', 'cpu'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "GET", "reports/all_commands", params={'sort_column': 'cpu'})
def test_state_invalid(self): sys.argv = ['qds.py', '--version', 'v2', 'cluster', 'list', '--state', 'invalid'] Qubole.cloud = None print_command() Connection._api_call = Mock(return_value=[{"cluster" : {"state" : "invalid"}}]) qds.main() Connection._api_call.assert_called_with('GET', 'clusters', params=None)
def test_minimal(self): sys.argv = ['qds.py', '--version', 'v2', 'cluster', 'update', '123'] Qubole.cloud = None print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with('PUT', 'clusters/123', {})
def test_all(self): sys.argv = ['qds.py', 'account', 'create', '--name', 'new_account', '--location', 's3://bucket/path', '--storage-access-key', 'dummy', '--storage-secret-key', 'dummy', '--compute-access-key', 'dummy', '--compute-secret-key', 'dummy', '--previous-account-plan', 'true', '--aws-region', 'us-east-1'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("POST", "account", {'account': { 'name': 'new_account', 'acc_key': 'dummy', 'level': 'free', 'compute_type': 'CUSTOMER_MANAGED', 'aws_region': 'us-east-1', 'storage_type': 'CUSTOMER_MANAGED', 'CacheQuotaSizeInGB': '25', 'secret': 'dummy', 'use_previous_account_plan': 'true', 'compute_secret_key': 'dummy', 'compute_access_key': 'dummy', 'defloc': 's3://bucket/path'}})
def test_minimal(self): sys.argv = ['qds.py', '--version', 'v2', 'cluster', 'list'] Qubole.cloud = None print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with('GET', 'clusters', params=None)
def test_file_sensor(self): sys.argv = ['qds.py', 'filesensor', 'check', '-d', '{"files":["s3://dev.canopydata.com/airflow"]}'] print_command() Connection._api_call = Mock(return_value={'status': True}) qds.main() Connection._api_call.assert_called_with( "POST", "sensors/file_sensor", {'files':['s3://dev.canopydata.com/airflow']})
def test_partition_sensor(self): sys.argv = ['qds.py', 'partitionsensor', 'check', '-d', '{"schema" : "default", "table" : "nation_s3_rcfile_p", "columns" : [{"column" : "p", "values" : [1, 2]}]}'] print_command() Connection._api_call = Mock(return_value={'status': True}) qds.main() Connection._api_call.assert_called_with( "POST", "sensors/partition_sensor", {"schema" : "default", "table" : "nation_s3_rcfile_p", "columns" : [{"column" : "p", "values" : [1, 2]}]})
def test_view(self): sys.argv = ['qds.py', 'action', 'view', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("GET", "actions/123", params=None)
def test_rerun(self): sys.argv = ['qds.py', 'action', 'rerun', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("POST", "actions/123/rerun", None)
def test_sparkcmd(self): sys.argv = ['qds.py', 'sparkcmd', 'cancel', '123'] print_command() Connection._api_call = Mock(return_value={'kill_succeeded': True}) qds.main() Connection._api_call.assert_called_with("PUT", "commands/123", {'status': 'kill'})
def test_list_pages(self): sys.argv = ['qds.py', 'action', 'list', '--per-page', '2'] print_command() Connection._api_call = Mock(return_value={"actions": []}) qds.main() Connection._api_call.assert_called_with("GET", "actions", params={'per_page': '2'})
def test_list_actions_seq_id(self): sys.argv = ['qds.py', 'scheduler', 'list-actions', '123', '--sequence_id', '123'] print_command() Connection._api_call = Mock() Connection._api_call.side_effect = list_actions_side_effect qds.main() Connection._api_call.assert_has_calls([call("GET", "scheduler/123",params=None), call("GET", "scheduler/123/actions/123", params={})])
def test_update_two_fields(self): sys.argv = ['qds.py', 'nezha', 'cubes', 'update', '123', '--cost', '100', '--query', 'select now()'] print_command() Connection._api_call = Mock(return_value={'nezha_cubes': []}) qds.main() Connection._api_call.assert_called_with( "PUT", "nezha_cubes/123", {'cost': '100', 'query': 'select now()'})
def test_update_two_fields(self): sys.argv = ['qds.py', 'nezha', 'data_sources', 'update', '123', '--url', 'http://test', '--name', 'test'] print_command() Connection._api_call = Mock(return_value={'nezha_data_sources': []}) qds.main() Connection._api_call.assert_called_with( "PUT", "nezha_data_sources/123", {'name': 'test', 'url': 'http://test'})
def test_update_schema_name(self): sys.argv = ['qds.py', 'nezha', 'cubes', 'update', '123', '--schema_name', 'something'] print_command() Connection._api_call = Mock(return_value={'nezha_cubes': []}) qds.main() Connection._api_call.assert_called_with( "PUT", "nezha_cubes/123", {'schema_name': 'something'})
def test_list_users(self): sys.argv = ['qds.py', 'group', 'list-users', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with( "GET", "groups/123/qbol_users", params=None)
def test_list_actions_pages_fields(self): sys.argv = ['qds.py', 'scheduler', 'list-actions', '123', '--per-page', '2', '--fields', 'id', 'sequence_id'] print_command() Connection._api_call = Mock() Connection._api_call.side_effect = list_actions_side_effect qds.main() Connection._api_call.assert_has_calls([call("GET","scheduler/123",params=None), call("GET", "scheduler/123/actions", params={'per_page':'2'})])
def test_unassign_role_neg(self): sys.argv = ['qds.py', 'role', 'unassign-role', '123', "--group-id"] print_command() Connection._api_call = Mock(return_value={}) with self.assertRaises(SystemExit): qds.main()
def test_minimal(self): sys.argv = ['qds.py', 'report', 'list'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("GET", "reports", params=None)
def test_dbtapquerycmd(self): sys.argv = ['qds.py', 'dbtapquerycmd', 'check', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("GET", "commands/123", params=None)
def test_fail_with_good_and_bad_config(self): sys.argv = ['qds.py', 'app', 'create', '--name', 'appname', '--config', 'this=good', 'no-equal-sign'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_list(self): sys.argv = ['qds.py', 'role', 'list'] print_command() Connection._api_call = Mock(return_value={'roles': []}) qds.main() Connection._api_call.assert_called_with("GET", "roles", params=None)
def test_submit_none(self): sys.argv = ['qds.py', 'prestocmd', 'submit'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_delete_neg(self): sys.argv = ['qds.py', 'nezha', 'delete', 'data_sources'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_view_neg(self): sys.argv = ['qds.py', 'nezha', 'view', 'partitions'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_delete_neg(self): sys.argv = ['qds.py', 'role', 'delete'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_delete(self): sys.argv = ['qds.py', 'role', 'delete', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("DELETE", "roles/123", None)
def test_view_template_without_id(self): sys.argv = ['qds.py', 'template', 'view'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_list_groups_neg(self): sys.argv = ['qds.py', 'role', 'list-groups'] print_command() Connection._api_call = Mock(return_value={}) with self.assertRaises(SystemExit): qds.main()
def test_invalid_template_operation(self): sys.argv = ['qds.py', 'template', 'load', '--id', '12'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_clone_template_without_id_data(self): sys.argv = ['qds.py', 'template', 'clone'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_submit_all_three(self): sys.argv = ['qds.py', 'sparkcmd', 'submit', '--cmdline', '/usr/lib/spark/bin/spark-submit --class Test Test.jar', '--script_location', '/home/path-to-script', 'program', 'println("hello, world!")'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_edit_template_without_data(self): sys.argv = ['qds.py', 'template', 'edit', '--id', '12'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_sort_invalid(self): sys.argv = ['qds.py', 'report', 'canonical_hive_commands', '--sort', 'invalid'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_program_no_language(self): sys.argv = ['qds.py', 'sparkcmd', 'submit', '--program', 'println("hello, world!")'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_submit_script_location_aws(self): sys.argv = ['qds.py', 'sparkcmd', 'submit', '--script_location', 's3://bucket/path-to-script'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_submit_both(self): sys.argv = ['qds.py', 'sparkcmd', 'submit', '--cmdline', '/usr/lib/spark/bin/spark-submit --class Test Test.jar', '--script_location', 'home/path-to-script'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_fail_with_no_argument(self): sys.argv = ['qds.py', 'app', 'create'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_fail_with_wrong_kind(self): sys.argv = ['qds.py', 'app', 'create', '--name', 'appname', '--kind', 'tez'] # tez apps are not supported yet. print_command() with self.assertRaises(SystemExit): qds.main()
def test_minimal(self): sys.argv = ['qds.py', 'app', 'show', '123'] print_command() Connection._api_call = Mock(return_value={}) qds.main() Connection._api_call.assert_called_with("GET", "apps/123", params=None)
def test_fail_with_bad_id(self): sys.argv = ['qds.py', 'app', 'show', 'notanumber'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_submit_streaming_invalid(self): sys.argv = ['qds.py', 'hadoopcmd', 'submit', 'streaming'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_fail_with_no_id(self): sys.argv = ['qds.py', 'app', 'stop'] print_command() with self.assertRaises(SystemExit): qds.main()
def test_submit_fail_with_no_parameters(self): sys.argv = ['qds.py', 'dbtapquerycmd', 'submit'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_submit_fail_with_only_db_tap_id_passed(self): sys.argv = ['qds.py', 'dbtapquerycmd', 'submit', '--db_tap_id', 1] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_submit_both(self): sys.argv = ['qds.py', 'prestocmd', 'submit', '--query', 'show tables', '--script_location', 's3://bucket/path-to-script'] print_command() with self.assertRaises(qds_sdk.exception.ParseError): qds.main()
def test_fail_with_bad_config_2(self): sys.argv = ['qds.py', 'app', 'create', '--name', 'appname', '--config', 'multiple=equal=sign'] print_command() with self.assertRaises(SystemExit): qds.main()