Пример #1
0
 def test_validate_returns_error_decimal_value_above_upper_limit(self):
     test_field_object = {"Type":"decimal", "UpperLimit":100}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":101}}
     validation_result = test_field.validate(test_data)
     self.assertFalse(validation_result.valid)
     self.assertEqual("Value '101' is greater than upper limit '100'", validation_result.details)
Пример #2
0
 def test_validate_returns_error_enum_value_not_in_set(self):
     test_field_object = {"Type":"enum", "Values":"[\"alpha\", \"beta\", \"gamma\"]"}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":"delta"}}
     validation_result = test_field.validate(test_data)
     self.assertFalse(validation_result.valid)
     self.assertEqual("Value 'delta' not in list of known values: [alpha, beta, gamma]", validation_result.details)
Пример #3
0
 def test_validate_returns_error_field_empty(self):
     test_field_object = {"Type":"decimal"}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":""}}
     validation_result = test_field.validate(test_data)
     self.assertFalse(validation_result.valid)
     self.assertEqual("Field empty", validation_result.details)
Пример #4
0
 def test_validate_returns_error_unparsable_timestamp(self):
     test_field_object = {"Type":"timestamp", "LatestTime":"2019-03-14T14:54:20.000Z"}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":"invalidTimeStamp"}}
     validation_result = test_field.validate(test_data)
     self.assertFalse(validation_result.valid)
     self.assertEqual("Failed to perform timestamp validation, error: ('Unknown string format:', 'invalidTimeStamp')", validation_result.details)
Пример #5
0
 def test_validate_returns_error_timestamp_after_latest_time(self):
     test_field_object = {"Type":"timestamp", "LatestTime":"2019-03-14T14:54:20.000Z"}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":"2019-03-14T14:56:20.000Z"}}
     validation_result = test_field.validate(test_data)
     self.assertFalse(validation_result.valid)
     self.assertEqual("Timestamp value '2019-03-14 14:56:20+00:00' occurs after latest limit '2019-03-14 14:54:20+00:00'", validation_result.details)
Пример #6
0
 def test_validate_returns_error_decimal_value_below_lower_limit(self):
     test_field_object = {"Type":"decimal", "LowerLimit":50}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":49}}
     validation_result = test_field.validate(test_data)
     self.assertFalse(validation_result.valid)
     self.assertEqual("Value '49' is less than lower limit '50'", validation_result.details)
Пример #7
0
 def test_validate_returns_succeeds_value_equals_upper_limit(self):
     test_field_object = {"Type":"decimal", "UpperLimit":100}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":100}}
     validation_result = test_field.validate(test_data)
     self.assertTrue(validation_result.valid)
Пример #8
0
 def test_validate_returns_succeeds_enum_value_in_set(self):
     test_field_object = {"Type":"enum", "Values":"[\"alpha\", \"beta\", \"gamma\"]"}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":"alpha"}}
     validation_result = test_field.validate(test_data)
     self.assertTrue(validation_result.valid)
Пример #9
0
 def test_validate_returns_success_timestamp_after_earliest_time(self):
     test_field_object = {"Type":"timestamp", "EarliestTime":"2019-03-14T14:54:20.000Z"}
     test_field = Field("a.b", test_field_object)
     test_data = {"a":{"b":"2019-03-14T14:54:21.000Z"}}
     validation_result = test_field.validate(test_data)
     self.assertTrue(validation_result.valid)