Esempio n. 1
0
def test_get_reservation_exception(client_constructor):
    grpc_client = setup_mock_(client_constructor)
    grpc_client.get_quantum_reservation.side_effect = exceptions.BadRequest(
        'boom')

    client = EngineClient()
    with pytest.raises(EngineException, match='boom'):
        client.get_reservation('proj', 'processor0', 'goog')
Esempio n. 2
0
def test_get_reservation_not_found(client_constructor):
    grpc_client = setup_mock_(client_constructor)
    name = 'projects/proj/processors/processor0/reservations/papar-party-44'
    grpc_client.get_quantum_reservation.side_effect = exceptions.NotFound(
        'not found')

    client = EngineClient()
    assert (client.get_reservation('proj', 'processor0',
                                   'papar-party-44') == None)
    kwargs = grpc_client.get_quantum_reservation.call_args[1]
    assert kwargs == {
        'name': name,
    }
Esempio n. 3
0
def test_get_reservation(client_constructor):
    grpc_client = setup_mock_(client_constructor)
    name = 'projects/proj/processors/processor0/reservations/papar-party-44'
    result = qtypes.QuantumReservation(
        name=name,
        start_time=Timestamp(seconds=1000000000),
        end_time=Timestamp(seconds=1000002000),
        whitelisted_users=['*****@*****.**'],
    )
    grpc_client.get_quantum_reservation.return_value = result

    client = EngineClient()
    assert (client.get_reservation('proj', 'processor0',
                                   'papar-party-44') == result)
    kwargs = grpc_client.get_quantum_reservation.call_args[1]
    assert kwargs == {
        'name': name,
    }