Example #1
0
    def test_comparision(self):
        success_result = core.ValidationResult(success=True)
        failure_result = core.ValidationResult(success=False)
        self.assertEqual(success_result, True)
        self.assertEqual(failure_result, False)
        self.assertNotEqual(success_result, failure_result)

        # comparision with other types should raise false
        self.assertFalse(success_result == 1)
Example #2
0
 def test_permission_result_delegates_errors_and_error_code(self):
     exception = exceptions.LogicException("test",
                                           error_code="CODE",
                                           errors=object())
     result = core.ValidationResult(success=False, error=exception)
     self.assertEqual(result.error_code, exception.error_code)
     self.assertEqual(result.errors, exception.errors)
Example #3
0
 def test_unicode_is_handled_properly(self):
     unicode_text = u'Zażółć gęślą jaźń'
     result = core.ValidationResult(success=False, error=exceptions.LogicException(unicode_text))
     self.assertEqual(u'{}'.format(result), unicode_text)
Example #4
0
 def test_permission_result_repr(self):
     result_success = core.ValidationResult(success=True)
     self.assertEqual(
         repr(result_success),
         u'<PermissionResult success=True error=None>')
Example #5
0
 def test_permission_result_delegates_returns_none_if_no_error(self):
     result = core.ValidationResult(success=True, error=None)
     self.assertIsNone(result.error_code)
     self.assertIsNone(result.errors)
Example #6
0
 def test_permission_result_coercible_to_bool(self):
     result_success = core.ValidationResult(success=True)
     result_failure = core.ValidationResult(success=False)
     self.assertTrue(result_success)
     self.assertFalse(result_failure)
Example #7
0
 def test_string_representation_equals_to_error(self):
     result = core.ValidationResult(success=False, error=Exception("Test error"))
     self.assertEqual(str(result), "Test error")