Exemplo n.º 1
0
        def test_is_required(self, valid_occurrence):
            with pytest.raises(ValidationError) as excinfo:
                Occurrence(**dissoc(valid_occurrence, "state"))

            self.assert_validation_error("value_error.missing", excinfo)
Exemplo n.º 2
0
        def test_must_be_datetime(self, valid_occurrence):
            with pytest.raises(ValidationError) as excinfo:
                Occurrence(
                    **assoc(valid_occurrence, "created_at", "some datetime"))

            self.assert_validation_error("value_error.datetime", excinfo)
Exemplo n.º 3
0
        def test_must_be_state(self, valid_occurrence):
            with pytest.raises(ValidationError) as excinfo:
                Occurrence(**assoc(valid_occurrence, "state", "some state"))

            self.assert_validation_error("type_error.enum", excinfo)
Exemplo n.º 4
0
        def test_must_be_int(self, valid_occurrence):
            with pytest.raises(ValidationError) as excinfo:
                Occurrence(**assoc(valid_occurrence, "id", "some id"))

            self.assert_validation_error("type_error.integer", excinfo)
Exemplo n.º 5
0
 def test_immutability(self, valid_occurrence):
     entity = Occurrence(**valid_occurrence)
     for key in entity.dict().keys():
         with pytest.raises(TypeError):
             setattr(entity, key, "some value")
Exemplo n.º 6
0
 def test_invalidation(self, invalid_occurrence):
     with pytest.raises(ValidationError):
         Occurrence(**invalid_occurrence)
Exemplo n.º 7
0
 def test_validation(self, valid_occurrence):
     assert Occurrence(**valid_occurrence)