Exemplo n.º 1
0
def test_login(monkeypatch):
    def get_access_url_mock(arg1, arg2):
        return "some.url"

    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    dummyTapHandler = DummyTapHandler()
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    user = '******'
    password = '******'
    cert = 'cert'
    # default parameters
    parameters = {}
    parameters['cookie_prefix'] = cadc_core.CADC_COOKIE_PREFIX
    parameters['login_url'] = "some.url"
    parameters['verbose'] = False
    parameters['user'] = None
    parameters['password'] = None
    parameters['certificate_file'] = None
    tap.login(None, None, None)
    dummyTapHandler.check_call('login', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['user'] = user
    parameters['password'] = password
    parameters['certificate_file'] = cert
    tap.login(user, password, cert)
    dummyTapHandler.check_call('login', parameters)
Exemplo n.º 2
0
def test_login(monkeypatch):
    def get_access_url_mock(arg1, arg2):
        return "some.url"

    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    dummyTapHandler = DummyTapHandler()
    tap = CadcClass(tap_plus_handler=dummyTapHandler)
    user = '******'
    password = '******'
    cert = 'cert'
    # default parameters
    parameters = {}
    parameters['cookie_prefix'] = cadc_core.CADC_COOKIE_PREFIX
    parameters['login_url'] = "some.url"
    parameters['verbose'] = False
    parameters['user'] = None
    parameters['password'] = None
    parameters['certificate_file'] = None
    tap.login(None, None, None)
    dummyTapHandler.check_call('login', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['user'] = user
    parameters['password'] = password
    parameters['certificate_file'] = cert
    tap.login(user, password, cert)
    dummyTapHandler.check_call('login', parameters)
Exemplo n.º 3
0
def test_logout(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = CadcClass(tap_plus_handler=dummyTapHandler)
    # default parameters
    parameters = {}
    parameters['verbose'] = False
    tap.logout(False)
    dummyTapHandler.check_call('logout', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['verbose'] = True
    tap.logout(True)
    dummyTapHandler.check_call('logout', parameters)
Exemplo n.º 4
0
def test_logout(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    # default parameters
    parameters = {}
    parameters['verbose'] = False
    tap.logout(False)
    dummyTapHandler.check_call('logout', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['verbose'] = True
    tap.logout(True)
    dummyTapHandler.check_call('logout', parameters)
Exemplo n.º 5
0
def test_list_async_jobs(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    # default parameters
    parameters = {}
    parameters['verbose'] = False
    tap.list_async_jobs()
    dummyTapHandler.check_call('list_async_jobs', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['verbose'] = True
    tap.list_async_jobs(verbose=True)
    dummyTapHandler.check_call('list_async_jobs', parameters)
Exemplo n.º 6
0
def test_load_async_job(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = CadcClass(tap_plus_handler=dummyTapHandler)
    jobid = '123'
    # default parameters
    parameters = {}
    parameters['jobid'] = jobid
    parameters['verbose'] = False
    tap.load_async_job(jobid)
    dummyTapHandler.check_call('load_async_job', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['jobid'] = jobid
    parameters['verbose'] = True
    tap.load_async_job(jobid, verbose=True)
    dummyTapHandler.check_call('load_async_job', parameters)
Exemplo n.º 7
0
def test_get_table(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    # default parameters
    parameters = {}
    parameters['table'] = 'table'
    parameters['verbose'] = False
    tap.get_table('table')
    dummyTapHandler.check_call('get_table', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters = {}
    parameters['table'] = 'table'
    parameters['verbose'] = True
    tap.get_table('table', verbose=True)
    dummyTapHandler.check_call('get_table', parameters)
Exemplo n.º 8
0
def test_get_tables(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    # default parameters
    parameters = {}
    parameters['only_names'] = False
    parameters['verbose'] = False
    tap.get_tables()
    dummyTapHandler.check_call('get_tables', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters = {}
    parameters['only_names'] = True
    parameters['verbose'] = True
    tap.get_tables(True, True)
    dummyTapHandler.check_call('get_tables', parameters)
Exemplo n.º 9
0
def test_load_async_job(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    jobid = '123'
    # default parameters
    parameters = {}
    parameters['jobid'] = jobid
    parameters['verbose'] = False
    tap.load_async_job(jobid)
    dummyTapHandler.check_call('load_async_job', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['jobid'] = jobid
    parameters['verbose'] = True
    tap.load_async_job(jobid, verbose=True)
    dummyTapHandler.check_call('load_async_job', parameters)
Exemplo n.º 10
0
def test_save_results(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = CadcClass(tap_plus_handler=dummyTapHandler)
    job = '123'
    # default parameters
    parameters = {}
    parameters['job'] = job
    parameters['filename'] = 'file.txt'
    parameters['verbose'] = False
    tap.save_results(job, 'file.txt')
    dummyTapHandler.check_call('save_results', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['job'] = job
    parameters['filename'] = 'file.txt'
    parameters['verbose'] = True
    tap.save_results(job, 'file.txt', verbose=True)
    dummyTapHandler.check_call('save_results', parameters)
Exemplo n.º 11
0
def test_save_results(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    job = '123'
    # default parameters
    parameters = {}
    parameters['job'] = job
    parameters['filename'] = 'file.txt'
    parameters['verbose'] = False
    tap.save_results(job, 'file.txt')
    dummyTapHandler.check_call('save_results', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters['job'] = job
    parameters['filename'] = 'file.txt'
    parameters['verbose'] = True
    tap.save_results(job, 'file.txt', verbose=True)
    dummyTapHandler.check_call('save_results', parameters)
Exemplo n.º 12
0
def test_run_query(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = CadcClass(tap_plus_handler=dummyTapHandler)
    query = "query"
    operation = 'sync'
    # default parameters
    parameters = {}
    parameters['query'] = query
    parameters['name'] = None
    parameters['output_file'] = None
    parameters['output_format'] = 'votable'
    parameters['verbose'] = False
    parameters['dump_to_file'] = False
    parameters['upload_resource'] = None
    parameters['upload_table_name'] = None
    tap.run_query(query, operation)
    dummyTapHandler.check_call('run_query', parameters)
    # test with parameters
    dummyTapHandler.reset()
    output_file = 'output'
    output_format = 'format'
    verbose = True
    upload_resource = 'upload_res'
    upload_table_name = 'upload_table'
    parameters['query'] = query
    parameters['name'] = None
    parameters['output_file'] = output_file
    parameters['output_format'] = output_format
    parameters['verbose'] = verbose
    parameters['dump_to_file'] = True
    parameters['upload_resource'] = upload_resource
    parameters['upload_table_name'] = upload_table_name
    tap.run_query(query,
                  operation,
                  output_file=output_file,
                  output_format=output_format,
                  verbose=verbose,
                  upload_resource=upload_resource,
                  upload_table_name=upload_table_name)
    dummyTapHandler.check_call('run_query', parameters)
Exemplo n.º 13
0
def test_run_query(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = Cadc(tap_plus_handler=dummyTapHandler)
    query = "query"
    operation = 'sync'
    # default parameters
    parameters = {}
    parameters['query'] = query
    parameters['name'] = None
    parameters['output_file'] = None
    parameters['output_format'] = 'votable'
    parameters['verbose'] = False
    parameters['dump_to_file'] = False
    parameters['upload_resource'] = None
    parameters['upload_table_name'] = None
    tap.run_query(query, operation)
    dummyTapHandler.check_call('run_query', parameters)
    # test with parameters
    dummyTapHandler.reset()
    output_file = 'output'
    output_format = 'format'
    verbose = True
    upload_resource = 'upload_res'
    upload_table_name = 'upload_table'
    parameters['query'] = query
    parameters['name'] = None
    parameters['output_file'] = output_file
    parameters['output_format'] = output_format
    parameters['verbose'] = verbose
    parameters['dump_to_file'] = True
    parameters['upload_resource'] = upload_resource
    parameters['upload_table_name'] = upload_table_name
    tap.run_query(query,
                  operation,
                  output_file=output_file,
                  output_format=output_format,
                  verbose=verbose,
                  upload_resource=upload_resource,
                  upload_table_name=upload_table_name)
    dummyTapHandler.check_call('run_query', parameters)
Exemplo n.º 14
0
def test_get_tables(monkeypatch):
    dummyTapHandler = DummyTapHandler()
    monkeypatch.setattr(cadc_core, 'get_access_url', get_access_url_mock)
    tap = CadcClass(tap_plus_handler=dummyTapHandler)

    # sanity check: make sure our Cadc instance is using the handler
    assert tap._cadctap == dummyTapHandler

    # default parameters
    parameters = {}
    parameters['only_names'] = False
    parameters['verbose'] = False
    tap.get_tables()
    dummyTapHandler.check_call('get_tables', parameters)
    # test with parameters
    dummyTapHandler.reset()
    parameters = {}
    parameters['only_names'] = True
    parameters['verbose'] = True
    tap.get_tables(True, True)
    dummyTapHandler.check_call('get_tables', parameters)