Beispiel #1
0
        def test_is_required(self, valid_location):
            with pytest.raises(ValidationError) as excinfo:
                Location(**dissoc(valid_location, "lng"))

            self.assert_validation_error("value_error.missing", excinfo)
Beispiel #2
0
        def test_must_be_float(self, valid_location):
            with pytest.raises(ValidationError) as excinfo:
                Location(**{**valid_location, "lng": "some float"})

            self.assert_validation_error("type_error.float", excinfo)
Beispiel #3
0
 def test_immutability(self, valid_location):
     entity = Location(**valid_location)
     for key in entity.dict().keys():
         with pytest.raises(TypeError):
             setattr(entity, key, "some value")
Beispiel #4
0
 def test_invalidation(self, invalid_location):
     with pytest.raises(ValidationError):
         Location(**invalid_location)
Beispiel #5
0
 def test_validation(self, valid_location):
     assert Location(**valid_location)
Beispiel #6
0
 def location(self) -> Location:
     lat, lng = fake.latlng()
     return Location(lat=float(lat), lng=float(lng))