def testMeasurementUpdateStateByIdAsync(self): test_path = 'test/path' token_id = str(uuid.uuid4()) target_state = upload_completion_token.State.COMPLETED token_key = upload_completion_token.Token(id=token_id).put() upload_completion_token.Measurement(id=test_path, parent=token_key).put() upload_completion_token.Measurement.UpdateStateByIdAsync( None, token_id, target_state).wait() upload_completion_token.Measurement.UpdateStateByIdAsync( test_path, None, target_state).wait() upload_completion_token.Measurement.UpdateStateByIdAsync( 'expired', token_id, target_state).wait() measurement = upload_completion_token.Measurement.get_by_id( test_path, parent=token_key) self.assertNotEqual(measurement.state, target_state) self.assertEqual(measurement.error_message, None) upload_completion_token.Measurement.UpdateStateByIdAsync( test_path, token_id, target_state).wait() measurement = upload_completion_token.Measurement.get_by_id( test_path, parent=token_key) self.assertEqual(measurement.state, target_state) self.assertEqual(measurement.error_message, None)
def testMeasurementUpdateStateByIdAsync_ErrorMessageFaile(self): test_path = 'test/path' token_id = str(uuid.uuid4()) token_key = upload_completion_token.Token(id=token_id).put() upload_completion_token.Measurement(id=test_path, parent=token_key).put() upload_completion_token.Measurement.UpdateStateByIdAsync( test_path, token_id, upload_completion_token.State.FAILED, 'Some message').wait()
def testMeasurementUpdateStateByPathAsync_ErrorMessageFail(self): test_path = 'test/path' token_id = str(uuid.uuid4()) token_key = upload_completion_token.Token(id=token_id).put() upload_completion_token.Measurement(id=str(uuid.uuid4()), test_path=test_path, token=token_key).put() upload_completion_token.Measurement.UpdateStateByPathAsync( test_path, token_id, upload_completion_token.State.COMPLETED, 'Some message').check_success()
def testMeasurementUpdateStateByIdAsync_ErrorMessage(self): test_path = 'test/path' token_id = str(uuid.uuid4()) target_state = upload_completion_token.State.FAILED target_message = 'Some message' token_key = upload_completion_token.Token(id=token_id).put() upload_completion_token.Measurement(id=test_path, parent=token_key).put() upload_completion_token.Measurement.UpdateStateByIdAsync( test_path, token_id, target_state, target_message).wait() measurement = upload_completion_token.Measurement.get_by_id( test_path, parent=token_key) self.assertEqual(measurement.state, target_state) self.assertEqual(measurement.error_message, target_message)