def testValidate_StringNotInNestedOptionList_Fails(self): with self.assertRaises(ValueError): utils.Validate({'values': { 'nested_values': ['orange', 'banana'] }}, {'values': { 'nested_values': 'apple' }})
def testValidate_HasExpectedProperties_Passes(self): utils.Validate({ 'status': str, 'try_job_id': int }, { 'status': 'completed', 'try_job_id': 1234 })
def testValidate_InvalidTypeInDict_Fails(self): with self.assertRaises(ValueError): utils.Validate({ 'status': int, 'try_job_id': int }, { 'status': 'completed', 'try_job_id': 1234 })
def testValidate_MissingProperty_Fails(self): with self.assertRaises(ValueError): utils.Validate( { 'status': str, 'try_job_id': int, 'required_property': int }, { 'status': 'completed', 'try_job_id': 1234 })
def VerifyBisectFYIResults(job): """Verifies the bisect results against expected results in test config. Args: job: TryJob entity. Returns: A message with the missing properties, otherwise returns an empty string. """ expected_results = _GetBisectConfig(job).get('expected_results') try: utils.Validate(expected_results, job.results_data) except ValueError as e: return 'Bisect result is not as expected: %s.' % e return ''
def _ValidateResultsData(results_data): utils.Validate(_EXPECTED_RESULT_PROPERTIES, results_data)
def testValidate_TypeConversion_Passes(self): utils.Validate([1], '1')
def testValidate_StringInNestedOptionList_Passes(self): utils.Validate({'values': { 'nested_values': ['orange', 'banana'] }}, {'values': { 'nested_values': 'orange' }})
def testValidate_StringInOptionList_Passes(self): utils.Validate(str, 'a string')
def testValidate_ExpectedValueIsNone_Passes(self): utils.Validate(None, 'running')
def testValidate_MissingPropertyInNestedDict_Fails(self): with self.assertRaises(ValueError): utils.Validate({'values': { 'nested_values': ['orange', 'banana'] }}, {'values': {}})
def testValidate_InvalidType_Fails(self): with self.assertRaises(ValueError): utils.Validate(int, 'a string')
def testValidate_StringNotInOptionList_Fails(self): with self.assertRaises(ValueError): utils.Validate(['completed', 'pending', 'failed'], 'running')