def test_run_job(self): # Setup Expected Response name_2 = "name2-1052831874" description = "description-1724546052" schedule = "schedule-697920873" time_zone = "timeZone36848094" expected_response = { "name": name_2, "description": description, "schedule": schedule, "time_zone": time_zone, } expected_response = job_pb2.Job(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = scheduler_v1.CloudSchedulerClient() # Setup Request name = client.job_path("[PROJECT]", "[LOCATION]", "[JOB]") response = client.run_job(name) assert expected_response == response assert len(channel.requests) == 1 expected_request = cloudscheduler_pb2.RunJobRequest(name=name) actual_request = channel.requests[0][1] assert expected_request == actual_request
def test_update_job(self): # Setup Expected Response name = "name3373707" description = "description-1724546052" schedule = "schedule-697920873" time_zone = "timeZone36848094" expected_response = { "name": name, "description": description, "schedule": schedule, "time_zone": time_zone, } expected_response = job_pb2.Job(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = scheduler_v1.CloudSchedulerClient() # Setup Request job = {} update_mask = {} response = client.update_job(job, update_mask) assert expected_response == response assert len(channel.requests) == 1 expected_request = cloudscheduler_pb2.UpdateJobRequest( job=job, update_mask=update_mask ) actual_request = channel.requests[0][1] assert expected_request == actual_request