예제 #1
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")
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")
예제 #3
0
 def test_non_nullable_column(self):
     with pytest.raises(AssertionError):
         assert_nullable(self.user, 'age')
     with pytest.raises(AssertionError):
         assert_nullable(self.user, 'age')
예제 #4
0
 def test_nullable_column(self):
     assert_nullable(self.user, 'name')
     assert_nullable(self.user, 'name')
예제 #5
0
 def test_nullable_column(self, user):
     assert_nullable(user, 'name')
     assert_nullable(user, 'name')
예제 #6
0
 def test_updated_at_is_nullable(self, feedback):
     assert_nullable(feedback, 'updated_at')
예제 #7
0
 def test_updated_at_is_nullable(self, alternative):
     assert_nullable(alternative, 'updated_at')
예제 #8
0
 def test_hearing_id_is_nullable(self, alternative):
     assert_nullable(alternative, 'hearing_id')
예제 #9
0
 def test_closes_at_is_nullable(self, hearing):
     assert_nullable(hearing, 'closes_at')
예제 #10
0
 def test_opens_at_is_nullable(self, hearing):
     assert_nullable(hearing, 'opens_at')
예제 #11
0
 def test_updated_at_is_nullable(self, hearing):
     assert_nullable(hearing, 'updated_at')
예제 #12
0
 def test_updated_at_is_nullable(self, image):
     assert_nullable(image, 'updated_at')