示例#1
0
def database():
    """ Setup of the database before tests """

    db = DBConfig(db_name='resources/movies_test.sqlite')  # Creating new db
    with db.conn:
        try:
            db.c.execute("""CREATE TABLE IF NOT EXISTS MOVIES (
                        ID INTEGER PRIMARY KEY,
                        TITLE text,
                        YEAR integer, 
                        RUNTIME text, 
                        GENRE text, 
                        DIRECTOR text, 
                        CAST text, 
                        WRITER text, 
                        LANGUAGE text, 
                        COUNTRY text, 
                        AWARDS text, 
                        IMDb_Rating float, 
                        IMDb_votes integer, 
                        BOX_OFFICE integer,
                        UNIQUE(TITLE));
                        """)
        except sqlite3.IntegrityError as e:
            raise e

    yield db

    # Teardown - deleting the tested table
    db.c.execute("DROP TABLE MOVIES")
示例#2
0
def data_highscores():
    """ Setup of the data highscores class before tests """

    db = DBConfig(db_name='resources/movies_test.sqlite')  # Creating new db connection
    data_highscores = DataHighscores(db=db)

    yield data_highscores
示例#3
0
def data_sorter():
    """ Setup of the data sorter before tests """

    db = DBConfig(db_name='resources/movies_test.sqlite')  # Creating new db connection
    data_sorter = DataSorter(db=db)

    yield data_sorter
示例#4
0
def database():
    """ Setup of the database before tests """

    db = DBConfig(db_name='resources/movies_test.sqlite')  # Creating new db
    with db.conn:
        db.c.execute("""CREATE TABLE IF NOT EXISTS MOVIES (
                    ID INTEGER PRIMARY KEY,
                    TITLE text,
                    YEAR integer, 
                    RUNTIME text, 
                    GENRE text, 
                    DIRECTOR text, 
                    CAST text, 
                    WRITER text, 
                    LANGUAGE text, 
                    COUNTRY text, 
                    AWARDS text, 
                    IMDb_Rating float, 
                    IMDb_votes integer, 
                    BOX_OFFICE integer,
                    UNIQUE(TITLE));
                    """)

        try:
            db.c.execute("""INSERT INTO MOVIES(TITLE) VALUES ('The Shawshank Redemption')""")
            db.c.execute("""INSERT INTO MOVIES(TITLE) VALUES ('Memento')""")
            db.c.execute("""INSERT INTO MOVIES(TITLE) VALUES ('In Bruges')""")
            db.c.execute("""INSERT INTO MOVIES(TITLE) VALUES ('Gods')""")
            db.c.execute("""INSERT INTO MOVIES(TITLE) VALUES ('The Godfather')""")
        except sqlite3.IntegrityError:
            pass

    yield db
def data_compare():
    """ Setup of the data filter before tests """

    db = DBConfig(
        db_name='resources/movies_test.sqlite')  # Creating new db connection
    data_compare = DataCompare(db=db)

    yield data_compare