def location():
    drop_all_tables(test_conn, test_cursor)

    new_york = save(State(name='New York'), test_conn, test_cursor)
    pennsylvania = save(State(name='Pennsylvania'), test_conn, test_cursor)

    brooklyn = save(City(name='Brooklyn', state_id=new_york.id), test_conn,
                    test_cursor)
    manhattan = save(City(name='Manhattan', state_id=new_york.id), test_conn,
                     test_cursor)
    philadelphia = save(City(name='Philadelphia', state_id=pennsylvania.id),
                        test_conn, test_cursor)
    south_philly_zip = save(Zipcode(code=19019, city_id=philadelphia.id),
                            test_conn, test_cursor)
    chelsea_zip = save(Zipcode(code=10001, city_id=manhattan.id), test_conn,
                       test_cursor)
    dumbo_zip = save(Zipcode(code=11210, city_id=brooklyn.id), test_conn,
                     test_cursor)

    venue = save(Venue(name='Los Tacos Al Pastor', price=1), test_conn,
                 test_cursor)
    location = save(
        Location(longitude=40.7024,
                 latitude=-73.9875,
                 address='141 Front Street',
                 zipcode_id=dumbo_zip.id,
                 venue_id=venue.id), test_conn, test_cursor)
    yield location
    drop_all_tables(test_conn, test_cursor)
Ejemplo n.º 2
0
def build_category():
    db.drop_all_tables(test_conn, test_cursor)
    category = models.Category()
    category.name = 'Taco Places'
    db.save(category, test_conn, test_cursor)

    yield

    db.drop_all_tables(test_conn, test_cursor)
Ejemplo n.º 3
0
def tourist_spot():
    db.drop_all_tables(test_conn, test_cursor)

    new_york = db.save(models.State(name='New York'), test_conn, test_cursor)
    pennsylvania = db.save(models.State(name='Pennsylvania'), test_conn,
                           test_cursor)

    brooklyn = db.save(models.City(name='Brooklyn', state_id=new_york.id),
                       test_conn, test_cursor)
    manhattan = db.save(models.City(name='Manhattan', state_id=new_york.id),
                        test_conn, test_cursor)
    philadelphia = db.save(
        models.City(name='Philadelphia', state_id=pennsylvania.id), test_conn,
        test_cursor)
    south_philly_zip = db.save(
        models.Zipcode(code=19019, city_id=philadelphia.id), test_conn,
        test_cursor)
    chelsea_zip = db.save(models.Zipcode(code=10001, city_id=manhattan.id),
                          test_conn, test_cursor)
    dumbo_zip = db.save(models.Zipcode(code=11210, city_id=brooklyn.id),
                        test_conn, test_cursor)

    venue = db.save(
        models.Venue(name='Los Tacos Al Pastor',
                     price=1,
                     foursquare_id='4bf58dd8d48988d151941735'), test_conn,
        test_cursor)
    grimaldis = db.save(models.Venue(name='Grimaldis', price=2), test_conn,
                        test_cursor)
    pizza = db.save(models.Category(name='Pizza'), test_conn, test_cursor)
    tourist_spot = db.save(models.Category(name='Tourist Spot'), test_conn,
                           test_cursor)
    db.save(models.VenueCategory(venue_id=grimaldis.id, category_id=pizza.id),
            test_conn, test_cursor)
    db.save(
        models.VenueCategory(venue_id=grimaldis.id,
                             category_id=tourist_spot.id), test_conn,
        test_cursor)

    db.save(
        models.VenueCategory(venue_id=venue.id, category_id=tourist_spot.id),
        test_conn, test_cursor)
    grimaldi_location = db.save(
        models.Location(longitude=40.7024,
                        latitude=-73.9875,
                        address='1 Front Street',
                        zipcode_id=dumbo_zip.id,
                        venue_id=grimaldis.id), test_conn, test_cursor)
    taco_location = db.save(
        models.Location(longitude=40.7024,
                        latitude=-73.9875,
                        address='141 Front Street',
                        zipcode_id=dumbo_zip.id,
                        venue_id=venue.id), test_conn, test_cursor)
    yield tourist_spot
    db.drop_all_tables(test_conn, test_cursor)
def test_conn():
    # reference in  user and pasword from .env/settings.py
    test_conn = psycopg2.connect(dbname='mobilegaming_test',
                                 user='******',
                                 password='******')
    cursor = test_conn.cursor()
    db.drop_all_tables(test_conn, cursor)
    db.reset_all_primarykey(test_conn, cursor)
    yield test_conn
    db.drop_all_tables(test_conn, cursor)
    db.reset_all_primarykey(test_conn, cursor)
Ejemplo n.º 5
0
def clean_tables():
    db.drop_all_tables(test_conn, test_cursor)
    yield

    db.drop_all_tables(test_conn, test_cursor)
Ejemplo n.º 6
0
"""
seed.py file used to seed data into psql tables. 
fixed drop_all_tables() -> drop_records() using TRUNCATE to delete table with foreign key
added reset_all_primarykey to change primary keys back to 1 every time seed.py is run
"""

import psycopg2

import api.src.db as db
import api.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', 
    release_date = '2015-1-1', genre = 'casual', game_engine = 'Candy Factory'), db.conn, db.cursor)

amongus_ios = db.save(models.Game(name = 'Among Us', platform = 'iOS', publisher = 'Innersloth LLC', 
    release_date = '2018-11-2', genre = 'action', game_engine = 'Unity'), db.conn, db.cursor)
# breakpoint()
# seeding ratings
no1 = db.save(models.Rating(game_id = amongus.id, metacritic = 84, TS_rating = 4.465,