def test_get_device_specification(): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=quantum.QuantumProcessor()) assert processor.get_device_specification() is None # Construct expected device proto based on example expected = v2.device_pb2.DeviceSpecification() gs = expected.valid_gate_sets.add() gs.name = 'test_set' gates = gs.valid_gates.add() gates.id = 'x' gates.number_of_qubits = 1 gates.gate_duration_picos = 1000 gates.valid_targets.extend(['1q_targets']) expected.valid_qubits.extend(['0_0', '1_1']) target = expected.valid_targets.add() target.name = '1q_targets' target.target_ordering = v2.device_pb2.TargetSet.SYMMETRIC new_target = target.targets.add() new_target.ids.extend(['0_0']) processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(device_spec=_DEVICE_SPEC)) assert processor.get_device_specification() == expected
def test_supported_languages(): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=quantum.QuantumProcessor()) assert processor.supported_languages() == [] processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(supported_languages=['lang1', 'lang2']), ) assert processor.supported_languages() == ['lang1', 'lang2']
def test_expected_down_time(get_processor): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=quantum.QuantumProcessor()) assert not processor.expected_down_time() get_processor.return_value = quantum.QuantumProcessor( expected_down_time=Timestamp(seconds=1581515101) ) assert cg.EngineProcessor('a', 'p', EngineContext()).expected_down_time() == datetime.datetime( 2020, 2, 12, 13, 45, 1, tzinfo=datetime.timezone.utc ) get_processor.assert_called_once()
def test_expected_recovery_time(): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=quantum.QuantumProcessor()) assert not processor.expected_recovery_time() processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(expected_recovery_time=Timestamp(seconds=1581515101)), ) assert processor.expected_recovery_time() == datetime.datetime( 2020, 2, 12, 13, 45, 1, tzinfo=datetime.timezone.utc )
def test_sampler(client): client().create_program.return_value = ( 'prog', quantum.QuantumProgram(name='projects/proj/programs/prog'), ) client().create_job.return_value = ( 'job-id', quantum.QuantumJob(name='projects/proj/programs/prog/jobs/job-id', execution_status={'state': 'READY'}), ) client().get_job.return_value = quantum.QuantumJob( execution_status={'state': 'SUCCESS'}, update_time=_to_timestamp('2019-07-09T23:39:59Z')) client().get_job_results.return_value = quantum.QuantumResult( result=util.pack_any(_RESULTS_V2)) processor = cg.EngineProcessor('proj', 'mysim', EngineContext()) sampler = processor.get_sampler() results = sampler.run_sweep( program=_CIRCUIT, params=[cirq.ParamResolver({'a': 1}), cirq.ParamResolver({'a': 2})]) assert len(results) == 2 for i, v in enumerate([1, 2]): assert results[i].repetitions == 1 assert results[i].params.param_dict == {'a': v} assert results[i].measurements == {'q': np.array([[0]], dtype='uint8')} assert client().create_program.call_args[0][0] == 'proj'
def test_current_calibration(get_current_calibration): get_current_calibration.return_value = _CALIBRATION processor = cg.EngineProcessor('a', 'p', EngineContext()) calibration = processor.get_current_calibration() assert calibration.timestamp == 1562544000021 assert set(calibration.keys()) == {'xeb', 't1', 'globalMetric'} get_current_calibration.assert_called_once_with('a', 'p')
def test_get_schedule(list_time_slots): results = [ qtypes.QuantumTimeSlot( processor_name='potofgold', start_time=Timestamp(seconds=1000020000), end_time=Timestamp(seconds=1000040000), slot_type=qenums.QuantumTimeSlot.TimeSlotType.MAINTENANCE, maintenance_config=qtypes.QuantumTimeSlot.MaintenanceConfig( title='Testing', description='Testing some new configuration.', ), ), qtypes.QuantumTimeSlot( processor_name='potofgold', start_time=Timestamp(seconds=1000010000), end_time=Timestamp(seconds=1000020000), slot_type=qenums.QuantumTimeSlot.TimeSlotType.RESERVATION, reservation_config=qtypes.QuantumTimeSlot.ReservationConfig( project_id='super_secret_quantum'), ), ] list_time_slots.return_value = results processor = cg.EngineProcessor('proj', 'p0', EngineContext()) assert (processor.get_schedule( datetime.datetime.fromtimestamp(1000000000), datetime.datetime.fromtimestamp(1000050000)) == results) list_time_slots.assert_called_once_with( 'proj', 'p0', 'start_time < 1000050000 AND end_time > 1000000000')
def test_get_schedule_filter_by_time_slot(list_time_slots): results = [ quantum.QuantumTimeSlot( processor_name='potofgold', start_time=Timestamp(seconds=1000020000), end_time=Timestamp(seconds=1000040000), time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.MAINTENANCE, maintenance_config=quantum.QuantumTimeSlot.MaintenanceConfig( title='Testing', description='Testing some new configuration.'), ) ] list_time_slots.return_value = results processor = cg.EngineProcessor('proj', 'p0', EngineContext()) assert (processor.get_schedule( datetime.datetime.fromtimestamp(1000000000), datetime.datetime.fromtimestamp(1000050000), quantum.QuantumTimeSlot.TimeSlotType.MAINTENANCE, ) == results) list_time_slots.assert_called_once_with( 'proj', 'p0', 'start_time < 1000050000 AND end_time > 1000000000 AND ' + 'time_slot_type = MAINTENANCE', )
def test_expected_recovery_time(): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=qtypes.QuantumProcessor()) assert not processor.expected_recovery_time() processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=qtypes.QuantumProcessor( expected_recovery_time=qtypes.timestamp_pb2.Timestamp( seconds=1581515101)), ) assert processor.expected_recovery_time() == datetime.datetime( 2020, 2, 12, 13, 45, 1)
def test_list_reservation(list_reservations): name = 'projects/proj/processors/p0/reservations/rid' results = [ quantum.QuantumReservation( name=name, start_time=Timestamp(seconds=1000000000), end_time=Timestamp(seconds=1000003600), whitelisted_users=['*****@*****.**'], ), quantum.QuantumReservation( name=name + '2', start_time=Timestamp(seconds=1000003600), end_time=Timestamp(seconds=1000007200), whitelisted_users=['*****@*****.**'], ), ] list_reservations.return_value = results processor = cg.EngineProcessor('proj', 'p0', EngineContext()) assert ( processor.list_reservations( datetime.datetime.fromtimestamp(1000000000), datetime.datetime.fromtimestamp(1000010000) ) == results ) list_reservations.assert_called_once_with( 'proj', 'p0', 'start_time < 1000010000 AND end_time > 1000000000' )
def test_get_missing_device(): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=quantum.QuantumProcessor()) with pytest.raises(ValueError, match='device specification'): _ = processor.get_device(gate_sets=[_GATE_SET])
def test_health(get_processor): get_processor.return_value = quantum.QuantumProcessor(health=quantum.QuantumProcessor.Health.OK) processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(health=quantum.QuantumProcessor.Health.DOWN), ) assert processor.health() == 'OK'
def test_remove_reservation_not_found(get_reservation): get_reservation.return_value = None processor = cg.EngineProcessor( 'proj', 'p0', EngineContext(), quantum.QuantumProcessor(schedule_frozen_period=Duration(seconds=10000)), ) with pytest.raises(ValueError): processor.remove_reservation('rid')
def test_default_gate_sets(): # Sycamore should have valid gate sets with default processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor( device_spec=util.pack_any(known_devices.SYCAMORE_PROTO)), ) device = processor.get_device() device.validate_operation(cirq.X(cirq.GridQubit(5, 4))) # Test that a device with no standard gatesets doesn't blow up processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(device_spec=_DEVICE_SPEC)) device = processor.get_device() assert device.qubits == [cirq.GridQubit(0, 0), cirq.GridQubit(1, 1)]
def test_get_reservation(get_reservation): name = 'projects/proj/processors/p0/reservations/rid' result = quantum.QuantumReservation( name=name, start_time=Timestamp(seconds=1000000000), end_time=Timestamp(seconds=1000003600), whitelisted_users=['*****@*****.**'], ) get_reservation.return_value = result processor = cg.EngineProcessor('proj', 'p0', EngineContext()) assert processor.get_reservation('rid') == result get_reservation.assert_called_once_with('proj', 'p0', 'rid')
def test_remove_reservation_failures(get_reservation, get_processor): name = 'projects/proj/processors/p0/reservations/rid' now = int(datetime.datetime.now().timestamp()) result = quantum.QuantumReservation( name=name, start_time=Timestamp(seconds=now + 10), end_time=Timestamp(seconds=now + 3610), whitelisted_users=['*****@*****.**'], ) get_reservation.return_value = result get_processor.return_value = None # no processor processor = cg.EngineProcessor('proj', 'p0', EngineContext()) with pytest.raises(ValueError): processor.remove_reservation('rid') # No freeze period defined processor = cg.EngineProcessor('proj', 'p0', EngineContext(), quantum.QuantumProcessor()) with pytest.raises(ValueError): processor.remove_reservation('rid')
def test_get_device(): processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=qtypes.QuantumProcessor(device_spec=_DEVICE_SPEC)) device = processor.get_device(gate_sets=[_GATE_SET]) assert device.qubits == [cirq.GridQubit(0, 0), cirq.GridQubit(1, 1)] device.validate_operation(cirq.X(cirq.GridQubit(0, 0))) with pytest.raises(ValueError): device.validate_operation(cirq.X(cirq.GridQubit(1, 2))) with pytest.raises(ValueError): device.validate_operation(cirq.Y(cirq.GridQubit(0, 0)))
def test_get_device_specification(): processor = cg.EngineProcessor('a', 'p', EngineContext(), _processor=quantum.QuantumProcessor()) assert processor.get_device_specification() is None # Construct expected device proto based on example expected = v2.device_pb2.DeviceSpecification() expected.valid_qubits.extend(['0_0', '1_1', '2_2']) target = expected.valid_targets.add() target.name = '2_qubit_targets' target.target_ordering = v2.device_pb2.TargetSet.SYMMETRIC new_target = target.targets.add() new_target.ids.extend(['0_0', '1_1']) gate = expected.valid_gates.add() gate.cz.SetInParent() gate.gate_duration_picos = 1000 gate = expected.valid_gates.add() gate.phased_xz.SetInParent() processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(device_spec=_DEVICE_SPEC) ) assert processor.get_device_specification() == expected
def test_list_calibrations_old_params(list_calibrations): # Disable pylint warnings for use of deprecated parameters # pylint: disable=unexpected-keyword-arg list_calibrations.return_value = [_CALIBRATION] processor = cg.EngineProcessor('a', 'p', EngineContext()) with cirq.testing.assert_deprecated('Change earliest_timestamp_seconds', deadline='v1.0'): assert [ c.timestamp for c in processor.list_calibrations(earliest_timestamp_seconds=1562500000) ] == [1562544000021] list_calibrations.assert_called_with('a', 'p', 'timestamp >= 1562500000') with cirq.testing.assert_deprecated('Change latest_timestamp_seconds', deadline='v1.0'): assert [ c.timestamp for c in processor.list_calibrations(latest_timestamp_seconds=1562600000) ] == [1562544000021] list_calibrations.assert_called_with('a', 'p', 'timestamp <= 1562600000')
def test_get_device(): processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(device_spec=_DEVICE_SPEC) ) device = processor.get_device() assert device.metadata.qubit_set == frozenset( [cirq.GridQubit(0, 0), cirq.GridQubit(1, 1), cirq.GridQubit(2, 2)] ) device.validate_operation(cirq.X(cirq.GridQubit(2, 2))) device.validate_operation(cirq.CZ(cirq.GridQubit(0, 0), cirq.GridQubit(1, 1))) with pytest.raises(ValueError): device.validate_operation(cirq.X(cirq.GridQubit(1, 2))) with pytest.raises(ValueError): device.validate_operation(cirq.H(cirq.GridQubit(0, 0))) with pytest.raises(ValueError): device.validate_operation(cirq.CZ(cirq.GridQubit(1, 1), cirq.GridQubit(2, 2)))
def test_get_device(): processor = cg.EngineProcessor( 'a', 'p', EngineContext(), _processor=quantum.QuantumProcessor(device_spec=_DEVICE_SPEC)) device = processor.get_device(gate_sets=[_GATE_SET]) assert device.qubits == [cirq.GridQubit(0, 0), cirq.GridQubit(1, 1)] device.validate_operation(cirq.X(cirq.GridQubit(0, 0))) with pytest.raises(ValueError): device.validate_operation(cirq.X(cirq.GridQubit(1, 2))) with pytest.raises(ValueError): device.validate_operation(cirq.Y(cirq.GridQubit(0, 0))) with pytest.raises(ValueError, match='must be SerializableGateSet'): processor.get_device( gate_sets=[cg.serialization.circuit_serializer.CIRCUIT_SERIALIZER])
def test_update_reservation(update_reservation): name = 'projects/proj/processors/p0/reservations/rid' result = quantum.QuantumReservation( name=name, start_time=Timestamp(seconds=1000000000), end_time=Timestamp(seconds=1000003600), whitelisted_users=['*****@*****.**'], ) start = datetime.datetime.fromtimestamp(1000000000) end = datetime.datetime.fromtimestamp(1000003600) update_reservation.return_value = result processor = cg.EngineProcessor('proj', 'p0', EngineContext()) assert processor.update_reservation('rid', start, end, ['*****@*****.**']) == result update_reservation.assert_called_once_with( 'proj', 'p0', 'rid', start=start, end=end, whitelisted_users=['*****@*****.**'] )
def test_run_calibration(client): client().create_program.return_value = ( 'prog', qtypes.QuantumProgram(name='projects/proj/programs/prog'), ) client().create_job.return_value = ( 'job-id', qtypes.QuantumJob(name='projects/proj/programs/prog/jobs/job-id', execution_status={'state': 'READY'}), ) client().get_job.return_value = qtypes.QuantumJob( execution_status={'state': 'SUCCESS'}) client().get_job_results.return_value = qtypes.QuantumResult( result=_CALIBRATION_RESULTS_V2) q1 = cirq.GridQubit(2, 3) q2 = cirq.GridQubit(2, 4) layer1 = cg.CalibrationLayer('xeb', cirq.Circuit(cirq.CZ(q1, q2)), {'num_layers': 42}) layer2 = cg.CalibrationLayer('readout', cirq.Circuit(cirq.measure(q1, q2)), {'num_samples': 4242}) processor = cg.EngineProcessor('proj', 'mysim', EngineContext()) job = processor.run_calibration(gate_set=cg.FSIM_GATESET, layers=[layer1, layer2], job_id='job-id') results = job.calibration_results() assert len(results) == 2 assert results[0].code == v2.calibration_pb2.SUCCESS assert results[0].error_message == 'First success' assert results[0].token == 'abc123' assert len(results[0].metrics) == 1 assert len(results[0].metrics['fidelity']) == 1 assert results[0].metrics['fidelity'][(q1, q2)] == [0.75] assert results[1].code == v2.calibration_pb2.SUCCESS assert results[1].error_message == 'Second success' # assert label is correct client().create_job.assert_called_once_with( project_id='proj', program_id='prog', job_id='job-id', processor_ids=['mysim'], run_context=_to_any(v2.run_context_pb2.RunContext()), description=None, labels={'calibration': ''}, )
def test_run_batch(client): client().create_program.return_value = ( 'prog', quantum.QuantumProgram(name='projects/proj/programs/prog'), ) client().create_job.return_value = ( 'job-id', quantum.QuantumJob(name='projects/proj/programs/prog/jobs/job-id', execution_status={'state': 'READY'}), ) client().get_job.return_value = quantum.QuantumJob( execution_status={'state': 'SUCCESS'}, update_time=_to_timestamp('2019-07-09T23:39:59Z')) client().get_job_results.return_value = quantum.QuantumResult( result=_BATCH_RESULTS_V2) processor = cg.EngineProcessor('a', 'p', EngineContext()) job = processor.run_batch( programs=[_CIRCUIT, _CIRCUIT], job_id='job-id', params_list=[cirq.Points('a', [1, 2]), cirq.Points('a', [3, 4])], ) results = job.results() assert len(results) == 4 for i, v in enumerate([1, 2, 3, 4]): assert results[i].repetitions == 1 assert results[i].params.param_dict == {'a': v} assert results[i].measurements == {'q': np.array([[0]], dtype='uint8')} for result in results: assert result.job_id == job.id() client().create_program.assert_called_once() client().create_job.assert_called_once() run_context = v2.batch_pb2.BatchRunContext() client().create_job.call_args[1]['run_context'].Unpack(run_context) assert len(run_context.run_contexts) == 2 for idx, rc in enumerate(run_context.run_contexts): sweeps = rc.parameter_sweeps assert len(sweeps) == 1 assert sweeps[0].repetitions == 1 if idx == 0: assert sweeps[0].sweep.single_sweep.points.points == [1.0, 2.0] if idx == 1: assert sweeps[0].sweep.single_sweep.points.points == [3.0, 4.0] client().get_job.assert_called_once() client().get_job_results.assert_called_once()
def test_run_sweep_params(client): client().create_program.return_value = ( 'prog', quantum.QuantumProgram(name='projects/proj/programs/prog'), ) client().create_job.return_value = ( 'job-id', quantum.QuantumJob(name='projects/proj/programs/prog/jobs/job-id', execution_status={'state': 'READY'}), ) client().get_job.return_value = quantum.QuantumJob( execution_status={'state': 'SUCCESS'}, update_time=_to_timestamp('2019-07-09T23:39:59Z')) client().get_job_results.return_value = quantum.QuantumResult( result=util.pack_any(_RESULTS_V2)) processor = cg.EngineProcessor('a', 'p', EngineContext()) job = processor.run_sweep( program=_CIRCUIT, params=[cirq.ParamResolver({'a': 1}), cirq.ParamResolver({'a': 2})]) results = job.results() assert len(results) == 2 for i, v in enumerate([1, 2]): assert results[i].repetitions == 1 assert results[i].params.param_dict == {'a': v} assert results[i].measurements == {'q': np.array([[0]], dtype='uint8')} for result in results: assert result.job_id == job.id() assert result.job_finished_time is not None assert results == cirq.read_json(json_text=cirq.to_json(results)) client().create_program.assert_called_once() client().create_job.assert_called_once() run_context = v2.run_context_pb2.RunContext() client().create_job.call_args[1]['run_context'].Unpack(run_context) sweeps = run_context.parameter_sweeps assert len(sweeps) == 2 for i, v in enumerate([1.0, 2.0]): assert sweeps[i].repetitions == 1 assert sweeps[i].sweep.sweep_function.sweeps[ 0].single_sweep.points.points == [v] client().get_job.assert_called_once() client().get_job_results.assert_called_once()
def test_list_reservations_time_filter_behavior(list_reservations): list_reservations.return_value = [] processor = cg.EngineProcessor('proj', 'p0', EngineContext()) now = int(datetime.datetime.now().timestamp()) in_two_weeks = int( (datetime.datetime.now() + datetime.timedelta(weeks=2)).timestamp()) processor.list_reservations() list_reservations.assert_called_with( 'proj', 'p0', f'start_time < {in_two_weeks} AND end_time > {now}') with pytest.raises(ValueError, match='from_time of type'): processor.list_reservations(from_time=object()) with pytest.raises(ValueError, match='to_time of type'): processor.list_reservations(to_time=object()) processor.list_reservations(from_time=None, to_time=None) list_reservations.assert_called_with('proj', 'p0', '') processor.list_reservations(from_time=datetime.timedelta(0), to_time=None) list_reservations.assert_called_with('proj', 'p0', f'end_time > {now}') processor.list_reservations(from_time=datetime.timedelta(seconds=200), to_time=None) list_reservations.assert_called_with('proj', 'p0', f'end_time > {now + 200}') test_timestamp = datetime.datetime.utcfromtimestamp(52) utc_ts = int(test_timestamp.timestamp()) processor.list_reservations(from_time=test_timestamp, to_time=None) list_reservations.assert_called_with('proj', 'p0', f'end_time > {utc_ts}') processor.list_reservations(from_time=None, to_time=datetime.timedelta(0)) list_reservations.assert_called_with('proj', 'p0', f'start_time < {now}') processor.list_reservations(from_time=None, to_time=datetime.timedelta(seconds=200)) list_reservations.assert_called_with('proj', 'p0', f'start_time < {now + 200}') processor.list_reservations(from_time=None, to_time=test_timestamp) list_reservations.assert_called_with('proj', 'p0', f'start_time < {utc_ts}')
def test_remove_reservation_cancel(cancel_reservation, get_reservation): name = 'projects/proj/processors/p0/reservations/rid' now = int(datetime.datetime.now().timestamp()) result = quantum.QuantumReservation( name=name, start_time=Timestamp(seconds=now + 10), end_time=Timestamp(seconds=now + 3610), whitelisted_users=['*****@*****.**'], ) get_reservation.return_value = result cancel_reservation.return_value = result processor = cg.EngineProcessor( 'proj', 'p0', EngineContext(), quantum.QuantumProcessor(schedule_frozen_period=Duration(seconds=10000)), ) assert processor.remove_reservation('rid') == result cancel_reservation.assert_called_once_with('proj', 'p0', 'rid')
def test_run_sweep_params(client): client().create_program.return_value = ( 'prog', qtypes.QuantumProgram(name='projects/proj/programs/prog'), ) client().create_job.return_value = ( 'job-id', qtypes.QuantumJob(name='projects/proj/programs/prog/jobs/job-id', execution_status={'state': 'READY'}), ) client().get_job.return_value = qtypes.QuantumJob( execution_status={'state': 'SUCCESS'}) client().get_job_results.return_value = qtypes.QuantumResult( result=_to_any(_RESULTS_V2)) processor = cg.EngineProcessor('a', 'p', EngineContext()) job = processor.run_sweep( program=_CIRCUIT, params=[cirq.ParamResolver({'a': 1}), cirq.ParamResolver({'a': 2})], gate_set=cg.XMON, ) results = job.results() assert len(results) == 2 for i, v in enumerate([1, 2]): assert results[i].repetitions == 1 assert results[i].params.param_dict == {'a': v} assert results[i].measurements == {'q': np.array([[0]], dtype='uint8')} client().create_program.assert_called_once() client().create_job.assert_called_once() run_context = v2.run_context_pb2.RunContext() client().create_job.call_args[1]['run_context'].Unpack(run_context) sweeps = run_context.parameter_sweeps assert len(sweeps) == 2 for i, v in enumerate([1.0, 2.0]): assert sweeps[i].repetitions == 1 assert sweeps[i].sweep.sweep_function.sweeps[ 0].single_sweep.points.points == [v] client().get_job.assert_called_once() client().get_job_results.assert_called_once()
def test_list_calibrations(list_calibrations): list_calibrations.return_value = [_CALIBRATION] processor = cg.EngineProcessor('a', 'p', EngineContext()) assert [c.timestamp for c in processor.list_calibrations()] == [1562544000021] list_calibrations.assert_called_with('a', 'p', '') assert [c.timestamp for c in processor.list_calibrations(1562500000000) ] == [1562544000021] list_calibrations.assert_called_with('a', 'p', 'timestamp >= 1562500000000') assert [ c.timestamp for c in processor.list_calibrations( latest_timestamp_seconds=1562600000000) ] == [1562544000021] list_calibrations.assert_called_with('a', 'p', 'timestamp <= 1562600000000') assert [ c.timestamp for c in processor.list_calibrations(1562500000000, 1562600000000) ] == [1562544000021] list_calibrations.assert_called_with( 'a', 'p', 'timestamp >= 1562500000000 AND timestamp <= 1562600000000')
def test_create_reservation(create_reservation): name = 'projects/proj/processors/p0/reservations/psherman-wallaby-way' result = quantum.QuantumReservation( name=name, start_time=Timestamp(seconds=1000000000), end_time=Timestamp(seconds=1000003600), whitelisted_users=['*****@*****.**'], ) create_reservation.return_value = result processor = cg.EngineProcessor('proj', 'p0', EngineContext()) assert processor.create_reservation( datetime.datetime.fromtimestamp(1000000000), datetime.datetime.fromtimestamp(1000003600), ['*****@*****.**'], ) create_reservation.assert_called_once_with( 'proj', 'p0', datetime.datetime.fromtimestamp(1000000000), datetime.datetime.fromtimestamp(1000003600), ['*****@*****.**'], )