示例#1
0
def test_list_jobs_filters(client_constructor, expected_filter, created_before,
                           created_after, labels, execution_states):
    grpc_client = setup_mock_(client_constructor)
    client = EngineClient()
    client.list_jobs(project_id='proj',
                     program_id='prog',
                     created_before=created_before,
                     created_after=created_after,
                     has_labels=labels,
                     execution_states=execution_states)
    assert grpc_client.list_quantum_jobs.call_args[1] == {
        'filter_': expected_filter,
    }
示例#2
0
def test_list_jobs(client_constructor):
    grpc_client = setup_mock_(client_constructor)

    results = [
        qtypes.QuantumJob(name='projects/proj/programs/prog1/jobs/job1'),
        qtypes.QuantumJob(name='projects/proj/programs/prog1/jobs/job2')
    ]
    grpc_client.list_quantum_jobs.return_value = results

    client = EngineClient()
    assert client.list_jobs(project_id='proj', program_id='prog1') == results
    assert grpc_client.list_quantum_jobs.call_args[0] == (
        'projects/proj/programs/prog1', )
    assert grpc_client.list_quantum_jobs.call_args[1] == {
        'filter_': '',
    }

    assert client.list_jobs(project_id='proj') == results
    assert grpc_client.list_quantum_jobs.call_args[0] == (
        'projects/proj/programs/-', )
    assert grpc_client.list_quantum_jobs.call_args[1] == {
        'filter_': '',
    }