odapi/tests/queries_test.py

88 lines
2.2 KiB
Python
Raw Normal View History

2020-05-03 00:45:45 +02:00
from datetime import datetime
2020-09-11 00:07:45 +02:00
from pytest import fixture
from database.models import *
2020-08-02 19:46:56 +02:00
from tests import TestingSessionLocal
2020-07-24 19:27:15 +02:00
2020-08-02 19:46:56 +02:00
@fixture
def get_test_db():
try:
db = TestingSessionLocal()
yield db
finally:
db.close()
2020-08-02 19:46:56 +02:00
def test_users(get_test_db):
test = get_test_db.query(Users).filter(Users.id == 260).first()
assert test.email == "testaccountjugador@gmail.com"
2020-08-02 19:46:56 +02:00
def test_cities(get_test_db):
test = get_test_db.query(Cities).filter(Cities.id == 7).first()
assert test.name == "Lyon"
2020-08-02 19:46:56 +02:00
def test_games(get_test_db):
test = get_test_db.query(Games).filter(Games.id == 508).first()
2020-07-04 20:15:55 +02:00
assert test.user_id == 1978
2020-08-02 19:46:56 +02:00
def test_payments(get_test_db):
test = get_test_db.query(Payments).filter(Payments.id == 375).first()
assert test.user_id == 88
2020-08-02 19:46:56 +02:00
def test_player_availabilities(get_test_db):
test = (
get_test_db.query(PlayerAvailabilities)
.filter(PlayerAvailabilities.id == 248)
.first()
)
assert test.game_id == 89
2020-08-02 19:46:56 +02:00
def test_player_cancel_games(get_test_db):
test = (
get_test_db.query(PlayerCancelGames).filter(PlayerCancelGames.id == 67).first()
)
assert test.player_id == 44
2020-08-02 19:46:56 +02:00
def test_purchase_games(get_test_db):
test = get_test_db.query(PurchaseGames).filter(PurchaseGames.id == 235).first()
assert test.game_id == 50
2020-08-02 19:46:56 +02:00
def test_sports(get_test_db):
test = get_test_db.query(Sports).filter(Sports.id == 4).first()
assert test.name == "Volleyball"
2020-08-02 19:46:56 +02:00
def test_teams(get_test_db):
test = get_test_db.query(Teams).filter(Teams.id == 306).first()
assert test.game_id == 64
2020-08-02 19:46:56 +02:00
def test_user_ratings(get_test_db):
test = get_test_db.query(UserRatings).filter(UserRatings.id == 287).first()
assert test.user_id == 60
2020-08-02 19:46:56 +02:00
def test_venue_images(get_test_db):
test = get_test_db.query(VenueImages).filter(VenueImages.id == 3).first()
date = datetime(year=2019, month=6, day=3, hour=5, minute=43, second=22)
assert test.created == date
2020-08-02 19:46:56 +02:00
def test_venues(get_test_db):
test = get_test_db.query(Venues).filter(Venues.id == 26).first()
assert test.name == "Le tuto "
2020-08-02 19:46:56 +02:00
def test_web_bookings(get_test_db):
test = get_test_db.query(WebBookings).filter(WebBookings.id == 7).first()
assert test.game == "Soccer"