def run(self, TS_details, conn, cursor):
     selected = self.select_attributes(TS_details)
     game_name, game_platform = selected['name'], selected['platform']
     game = models.Game.find_by_game_name_platform(game_name, game_platform, cursor)
     if game:
         game.exists = True            
     else:
         selected['game_engine'] = self.IGDB_Client.find_game_engine(game_name)  # limited query allowance, tap when DNE          
         game = db.save(models.Game(**selected), conn, cursor)
         game.exists = False
     game.try_sibling_params_if_None(conn, cursor)
     return game
Ejemplo n.º 2
0
def test_update_column_for_games_table(test_conn):
    test_cursor = test_conn.cursor()
    g1 = {"id": 1, "name": "Among Us", "platform": "android", "publisher": "Innersloth LLC", "release_date": "2018-07-25", "genre": "action", "game_engine": "Unity"}
    game = db.save(models.Game(**g1), test_conn, test_cursor)
    
    game.game_engine = 'something_else'
    db.update_column(game, 'game_engine', test_conn, test_cursor)
    game.genre = 'Space Wars'
    db.update_column(game, 'genre', test_conn, test_cursor)
    
    game_update = db.find(models.Game, game.id, test_cursor)
    assert game_update.game_engine == 'something_else'
    assert game_update.genre == 'Space Wars'
Ejemplo n.º 3
0
"""

import psycopg2

import src.db as db
import src.models as models

# delete/truncate all tables and reset primary keys
db.drop_all_tables(db.conn, db.cursor)
db.reset_all_primarykey(db.conn, db.cursor)

# seeding games
amongus = db.save(
    models.Game(name='Among Us',
                platform='android',
                publisher='Innersloth LLC',
                release_date='2018-07-25',
                genre='action',
                game_engine='Unity'), db.conn, db.cursor)

roblox = db.save(
    models.Game(name='Roblox',
                platform='android',
                publisher='Roblox Corporation',
                release_date='2019-12-31',
                genre='building',
                game_engine='Something Else'), db.conn, db.cursor)

candy = db.save(
    models.Game(name='Candy Crush Saga',
                platform='android',
                publisher='King',
def test_Game_object_attributes():
    s3d_game = models.Game(**s3d_input)

    assert s3d_game.name == 'Sushi Roll 3D'
    assert s3d_game.genre == 'simulation'
Ejemplo n.º 5
0
def build_records_testing(conn, cursor):
    flask_r1 = {
        "id": 1,
        "game_id": 1,
        "metacritic": 84,
        "TS_rating": 4.43,
        "rank_type": "top free",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g1 = {
        "id": 1,
        "name": "Among Us",
        "platform": "android",
        "publisher": "Innersloth LLC",
        "release_date": "2018-07-25",
        "genre": "action",
        "game_engine": "Unity"
    }
    flask_e1 = {
        "id": 1,
        "game_id": 1,
        "price": 0.0,
        "inapp": True,
        "shows_ads": False,
        "revenue": 2000000,
        "downloads": 29000000
    }
    flask_r2 = {
        "id": 2,
        "game_id": 2,
        "metacritic": 83,
        "TS_rating": 4.53,
        "rank_type": "top paid",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g2 = {
        "id": 2,
        "name": "Minecraft",
        "platform": "android",
        "publisher": "Mojang",
        "release_date": "2009-05-10",
        "genre": "arcade",
        "game_engine": "Lightweight Java Game Library"
    }
    flask_e2 = {
        "id": 2,
        "game_id": 2,
        "price": 7.49,
        "inapp": True,
        "shows_ads": False,
        "revenue": 4000000,
        "downloads": 400000
    }
    flask_r3 = {
        "id": 3,
        "game_id": 3,
        "metacritic": None,
        "TS_rating": 4.42,
        "rank_type": "top grossing",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g3 = {
        "id": 3,
        "name": "Roblox",
        "platform": "android",
        "publisher": "Roblox Corporation",
        "release_date": None,
        "genre": "adventure",
        "game_engine": None
    }
    flask_e3 = {
        "id": 3,
        "game_id": 3,
        "price": 0.0,
        "inapp": True,
        "shows_ads": False,
        "revenue": 37000000,
        "downloads": 9000000
    }
    flask_r4 = {
        "id": 4,
        "game_id": 4,
        "metacritic": None,
        "TS_rating": 4.48,
        "rank_type": "top free",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g4 = {
        "id": 4,
        "name": "Among Us!",
        "platform": "iOS",
        "publisher": "InnerSloth LLC",
        "release_date": "2018-07-25",
        "genre": "action",
        "game_engine": "Unity"
    }
    flask_e4 = {
        "id": 4,
        "game_id": 4,
        "price": 0.0,
        "inapp": True,
        "shows_ads": False,
        "revenue": 6000000,
        "downloads": 12000000
    }
    flask_r5 = {
        "id": 5,
        "game_id": 5,
        "metacritic": 83,
        "TS_rating": 4.49,
        "rank_type": "top paid",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g5 = {
        "id": 5,
        "name": "Minecraft",
        "platform": "iOS",
        "publisher": "Mojang",
        "release_date": "2009-05-10",
        "genre": "arcade",
        "game_engine": "Lightweight Java Game Library"
    }
    flask_e5 = {
        "id": 5,
        "game_id": 5,
        "price": 6.99,
        "inapp": True,
        "shows_ads": True,
        "revenue": 10000000,
        "downloads": 300000
    }
    flask_r6 = {
        "id": 6,
        "game_id": 6,
        "metacritic": None,
        "TS_rating": 4.60,
        "rank_type": "top grossing",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g6 = {
        "id": 6,
        "name": "Roblox",
        "platform": "iOS",
        "publisher": "Roblox Corporation",
        "release_date": None,
        "genre": "adventure",
        "game_engine": None
    }
    flask_e6 = {
        "id": 6,
        "game_id": 6,
        "price": 0.0,
        "inapp": True,
        "shows_ads": True,
        "revenue": 60000000,
        "downloads": 4000000
    }

    db.save(models.Game(**flask_g1), conn, cursor)
    db.save(models.Game(**flask_g2), conn, cursor)
    db.save(models.Game(**flask_g3), conn, cursor)
    db.save(models.Game(**flask_g4), conn, cursor)
    db.save(models.Game(**flask_g5), conn, cursor)
    db.save(models.Game(**flask_g6), conn, cursor)
    db.save(models.Rating(**flask_r1), conn, cursor)
    db.save(models.Rating(**flask_r2), conn, cursor)
    db.save(models.Rating(**flask_r3), conn, cursor)
    db.save(models.Rating(**flask_r4), conn, cursor)
    db.save(models.Rating(**flask_r5), conn, cursor)
    db.save(models.Rating(**flask_r6), conn, cursor)
    db.save(models.Earnings(**flask_e1), conn, cursor)
    db.save(models.Earnings(**flask_e2), conn, cursor)
    db.save(models.Earnings(**flask_e3), conn, cursor)
    db.save(models.Earnings(**flask_e4), conn, cursor)
    db.save(models.Earnings(**flask_e5), conn, cursor)
    db.save(models.Earnings(**flask_e6), conn, cursor)
Ejemplo n.º 6
0
def build_records_testing_models(conn, cursor):
    flask_r1 = {
        "id": 1,
        "game_id": 1,
        "metacritic": 84,
        "TS_rating": 4.43,
        "rank_type": "top free",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g1 = {
        "id": 1,
        "name": "Among Us",
        "platform": "android",
        "publisher": "Innersloth LLC",
        "release_date": "2018-07-25",
        "genre": "action",
        "game_engine": "Unity"
    }
    flask_e1 = {
        "id": 1,
        "game_id": 1,
        "price": 0.0,
        "inapp": True,
        "shows_ads": False,
        "revenue": 2000000,
        "downloads": 29000000
    }
    flask_r2 = {
        "id": 2,
        "game_id": 2,
        "metacritic": None,
        "TS_rating": 4.48,
        "rank_type": "top free",
        "ranking": 1,
        "date_created": "2021-01-01"
    }
    flask_g2 = {
        "id": 2,
        "name": "Among Us!",
        "platform": "iOS",
        "publisher": "InnerSloth LLC",
        "release_date": None,
        "genre": "[6014,7001,7015]",
        "game_engine": None
    }
    flask_e2 = {
        "id": 2,
        "game_id": 2,
        "price": 0.0,
        "inapp": True,
        "shows_ads": False,
        "revenue": 6000000,
        "downloads": 12000000
    }

    db.save(models.Game(**flask_g1), conn, cursor)
    db.save(models.Game(**flask_g2), conn, cursor)
    db.save(models.Rating(**flask_r1), conn, cursor)
    db.save(models.Rating(**flask_r2), conn, cursor)
    db.save(models.Earnings(**flask_e1), conn, cursor)
    db.save(models.Earnings(**flask_e2), conn, cursor)