def test_profile_constraints(profile):
    assert_nullable(profile, "name")
    assert_max_length(profile, "name", 255)

    assert_non_nullable(profile, "email")
    assert_max_length(profile, "email", 255)

    assert_non_nullable(profile, "password")

    assert_nullable(profile, "birth_date")

    assert_nullable(profile, "best_friend_id")

    assert_non_nullable(profile, "_friend_count")
Ejemplo n.º 2
0
def test_shop_db_model_constraints(db_session: Session):
    owner = OwnerFactory()
    owner.create(db_session)

    shop = Shop(
        name="My Shop Name",
        address="My shop address",
        owner_id=owner.id,
        location="POINT(45 32)",
        radius_metres=500,
    )
    db_session.add(shop)
    db_session.commit()

    assert_non_nullable(shop, "id")
    assert_max_length(shop, "id", 100)

    assert_non_nullable(shop, "name")
    assert_max_length(shop, "name", 50)

    assert_non_nullable(shop, "address")
    assert_max_length(shop, "address", 50)

    assert_non_nullable(shop, "owner_id")
    assert_non_nullable(shop, "location")
    assert_non_nullable(shop, "radius_metres")
    assert_non_nullable(shop, "is_available")

    assert_nullable(shop, "phone_number")
Ejemplo n.º 3
0
 def test_username_max_length(self, user):
     assert_max_length(user, 'username', 255)
Ejemplo n.º 4
0
 def test_with_max_length(self):
     assert_max_length(self.user, 'name', 20)
     assert_max_length(self.user, 'name', 20)
Ejemplo n.º 5
0
 def test_bigger_than_max_length(self):
     with pytest.raises(AssertionError):
         assert_max_length(self.user, 'fav_numbers', 9)
     with pytest.raises(AssertionError):
         assert_max_length(self.user, 'fav_numbers', 9)
Ejemplo n.º 6
0
 def test_with_max_length(self):
     assert_max_length(self.user, 'fav_numbers', 8)
     assert_max_length(self.user, 'fav_numbers', 8)
Ejemplo n.º 7
0
 def test_bigger_than_max_length(self):
     with pytest.raises(AssertionError):
         assert_max_length(self.user, 'name', 21)
     with pytest.raises(AssertionError):
         assert_max_length(self.user, 'name', 21)
Ejemplo n.º 8
0
 def test_smaller_than_max_length(self):
     with pytest.raises(AssertionError):
         assert_max_length(self.user, 'name', 19)
     with pytest.raises(AssertionError):
         assert_max_length(self.user, 'name', 19)
Ejemplo n.º 9
0
 def test_with_non_nullable_column(self):
     assert_max_length(self.user, 'email', 200)
     assert_max_length(self.user, 'email', 200)
Ejemplo n.º 10
0
 def test_smaller_than_max_length(self, user):
     with pytest.raises(AssertionError):
         assert_max_length(user, 'fav_numbers', 7)
     with pytest.raises(AssertionError):
         assert_max_length(user, 'fav_numbers', 7)
Ejemplo n.º 11
0
 def test_title_max_length_is_255(self, alternative):
     assert_max_length(alternative, 'title', 255)
Ejemplo n.º 12
0
 def test_title_max_length_is_255(self, hearing):
     assert_max_length(hearing, 'title', 255)
Ejemplo n.º 13
0
 def test_filename_max_length_is_255(self, image):
     assert_max_length(image, 'filename', 255)