Пример #1
0
 def test_valid_when_side_effect_model(self):
     side_effect_model = Sample(pk=1)
     log = ManipulationLog()
     log.side_effect_model = side_effect_model
     with self.assertRaises(AssertionError):
         with self.assertRaises(ValidationError) as e:
             log.clean()
    def test_either_side_effect_model_or_uri_is_required(self):
        group_object = Sample.objects.create()
        trigger = Sample.objects.create()
        rule = Rule.objects.create(group_object=group_object)
        log = ManipulationLog(rule=rule, trigger_model=trigger)

        with self.assertRaises(ValidationError):
            log.full_clean()
    def test_side_effect_model_is_not_required_when_side_effect_uri(self):
        group_object = Sample.objects.create()
        trigger = Sample.objects.create()
        rule = Rule.objects.create(group_object=group_object)
        log = ManipulationLog(rule=rule, trigger_model=trigger, side_effect_uri="http://localhost/sample")

        with self.assertRaises(AssertionError):
            with self.assertRaises(ValidationError):
                log.full_clean()
Пример #4
0
 def test_requires_side_effect_model_or_uri(self):
     log = ManipulationLog()
     with self.assertRaises(ValidationError) as error_context:
         log.clean()
     self.assertEqual(["Side effect URI -or- Model is required."],
         error_context.exception.messages)
Пример #5
0
 def test_valid_when_side_effect_uri(self):
     log = ManipulationLog(side_effect_uri="foo")
     with self.assertRaises(AssertionError):
         with self.assertRaises(ValidationError):
             log.clean()