Example #1
0
 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", {})
Example #2
0
 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)
Example #3
0
 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'})
Example #4
0
 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)
Example #5
0
 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})])
Example #6
0
 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={})
Example #7
0
 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'})
Example #8
0
 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))
Example #9
0
 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))
Example #10
0
 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))
Example #11
0
 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})
Example #12
0
 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'}))
Example #13
0
 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})
Example #14
0
 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'})
Example #15
0
 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)
Example #16
0
 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', {})
Example #17
0
 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'}})
Example #18
0
 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)
Example #19
0
 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']})
Example #20
0
 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]}]})
Example #21
0
 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)
Example #22
0
 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)
Example #23
0
 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'})
Example #24
0
 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'})
Example #25
0
 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={})])
Example #26
0
 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()'})
Example #27
0
 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'})
Example #28
0
 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'})
Example #29
0
 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)
Example #30
0
 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'})])
Example #31
0
 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()
Example #32
0
 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)
Example #33
0
 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)
Example #34
0
 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()
Example #35
0
 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)
Example #36
0
 def test_submit_none(self):
     sys.argv = ['qds.py', 'prestocmd', 'submit']
     print_command()
     with self.assertRaises(qds_sdk.exception.ParseError):
         qds.main()
Example #37
0
 def test_delete_neg(self):
     sys.argv = ['qds.py', 'nezha', 'delete', 'data_sources']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #38
0
 def test_view_neg(self):
     sys.argv = ['qds.py', 'nezha', 'view', 'partitions']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #39
0
 def test_delete_neg(self):
     sys.argv = ['qds.py', 'role', 'delete']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #40
0
 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)
Example #41
0
 def test_view_template_without_id(self):
     sys.argv = ['qds.py', 'template', 'view']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #42
0
 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()
Example #43
0
 def test_invalid_template_operation(self):
     sys.argv = ['qds.py', 'template', 'load', '--id', '12']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #44
0
 def test_clone_template_without_id_data(self):
     sys.argv = ['qds.py', 'template', 'clone']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #45
0
 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()
Example #46
0
 def test_edit_template_without_data(self):
     sys.argv = ['qds.py', 'template', 'edit', '--id', '12']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #47
0
 def test_sort_invalid(self):
     sys.argv = ['qds.py', 'report', 'canonical_hive_commands',
                 '--sort', 'invalid']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #48
0
 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()
Example #49
0
 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()
Example #50
0
 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()
Example #51
0
 def test_fail_with_no_argument(self):
     sys.argv = ['qds.py', 'app', 'create']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #52
0
 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()
Example #53
0
 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)
Example #54
0
 def test_fail_with_bad_id(self):
     sys.argv = ['qds.py', 'app', 'show', 'notanumber']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #55
0
 def test_submit_streaming_invalid(self):
     sys.argv = ['qds.py', 'hadoopcmd', 'submit', 'streaming']
     print_command()
     with self.assertRaises(qds_sdk.exception.ParseError):
         qds.main()
Example #56
0
 def test_fail_with_no_id(self):
     sys.argv = ['qds.py', 'app', 'stop']
     print_command()
     with self.assertRaises(SystemExit):
         qds.main()
Example #57
0
 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()
Example #58
0
 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()
Example #59
0
 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()
Example #60
0
 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()