示例#1
0
 def testValidate_StringNotInNestedOptionList_Fails(self):
     with self.assertRaises(ValueError):
         utils.Validate({'values': {
             'nested_values': ['orange', 'banana']
         }}, {'values': {
             'nested_values': 'apple'
         }})
示例#2
0
 def testValidate_HasExpectedProperties_Passes(self):
     utils.Validate({
         'status': str,
         'try_job_id': int
     }, {
         'status': 'completed',
         'try_job_id': 1234
     })
示例#3
0
 def testValidate_InvalidTypeInDict_Fails(self):
     with self.assertRaises(ValueError):
         utils.Validate({
             'status': int,
             'try_job_id': int
         }, {
             'status': 'completed',
             'try_job_id': 1234
         })
示例#4
0
 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
             })
示例#5
0
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 ''
示例#6
0
def _ValidateResultsData(results_data):
    utils.Validate(_EXPECTED_RESULT_PROPERTIES, results_data)
示例#7
0
 def testValidate_TypeConversion_Passes(self):
     utils.Validate([1], '1')
示例#8
0
 def testValidate_StringInNestedOptionList_Passes(self):
     utils.Validate({'values': {
         'nested_values': ['orange', 'banana']
     }}, {'values': {
         'nested_values': 'orange'
     }})
示例#9
0
 def testValidate_StringInOptionList_Passes(self):
     utils.Validate(str, 'a string')
示例#10
0
 def testValidate_ExpectedValueIsNone_Passes(self):
     utils.Validate(None, 'running')
示例#11
0
 def testValidate_MissingPropertyInNestedDict_Fails(self):
     with self.assertRaises(ValueError):
         utils.Validate({'values': {
             'nested_values': ['orange', 'banana']
         }}, {'values': {}})
示例#12
0
 def testValidate_InvalidType_Fails(self):
     with self.assertRaises(ValueError):
         utils.Validate(int, 'a string')
示例#13
0
 def testValidate_StringNotInOptionList_Fails(self):
     with self.assertRaises(ValueError):
         utils.Validate(['completed', 'pending', 'failed'], 'running')