Ensure models are correct with query tests

This commit is contained in:
coolneng 2020-05-01 20:17:46 +02:00
parent 9763972575
commit ae6cd00e27
Signed by: coolneng
GPG Key ID: 9893DA236405AF57
4 changed files with 73 additions and 1 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
constants.py constants.py
assets/db_schema.sql assets/db_schema.sql
/**/__pycache__

View File

@ -273,7 +273,7 @@ class UserRatings(db.Model):
id = db.Column(db.Integer, primary_key=True, autoincrement=True) id = db.Column(db.Integer, primary_key=True, autoincrement=True)
game_id = db.Column(db.Integer) game_id = db.Column(db.Integer)
user_id = db.Column(db.Integer) user_id = db.Column(db.Integer)
player_id = db.Column(db.Enum("1", "2")) player_id = db.Column(db.Integer)
rating = db.Column(db.String(100)) rating = db.Column(db.String(100))
created = db.Column(db.DateTime, nullable=False, server_default=db.func.now()) created = db.Column(db.DateTime, nullable=False, server_default=db.func.now())
modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now()) modified = db.Column(db.DateTime, nullable=False, onupdate=db.func.now())

0
tests/__init__.py Normal file
View File

71
tests/queries_test.py Normal file
View File

@ -0,0 +1,71 @@
from app.models import *
def test_users():
deepak = Users.query.filter_by(id=46).first()
assert deepak.email == "deepak@yopmail.com"
def test_cities():
beirut = Cities.query.filter_by(id=12).first()
assert beirut.name == "Beirut"
def test_games():
test = Games.query.filter_by(id=63).first()
assert test.user_id == 255
def test_payments():
test = Payments.query.filter_by(id=295).first()
assert test.user_id == 260
def test_player_availabilities():
test = PlayerAvailabilities.query.filter_by(id=256).first()
assert test.game_id == 94
def test_player_cancel_games():
test = PlayerCancelGames.query.filter_by(id=132).first()
assert test.player_id == 137
def test_purchase_games():
test = PurchaseGames.query.filter_by(id=268).first()
assert test.game_id == 64
def test_sports():
test = Sports.query.filter_by(id=4).first()
assert test.name == "Volleyball"
def test_teams():
test = Teams.query.filter_by(id=306).first()
assert test.game_id == 64
def test_user_ratings():
test = UserRatings.query.filter_by(id=420).first()
assert test.user_id == 21
def test_venue_images():
test = VenueImages.query.filter_by(id=3).first()
assert test.user_id == 9
def test_venues():
test = Venues.query.filter_by(id=28).first()
assert test.name == "Santiago Bernabéu"
def test_view_news():
test = ViewNews.query.filter_by(id=57).first()
assert test.news_id == 10
def test_web_bookings():
test = WebBookings.query.filter_by(id=9).first()
assert test.game == "Fútbol "