Beispiel #1
0
 def setUp(self):
     db.create_all()
     review = Review(review='The Best Game Ever', game_id='1')
     game1 = Games(game='NieR:Automata')
     db.session.add(review)
     db.session.add(game1)
     db.session.commit()
Beispiel #2
0
 def test_one_game_page_view(self):
     # Check if a single game is accessible without login
     game = Games(game_name = 'Test Game', description = 'Test Description')
     db.session.add(game)
     db.session.commit()
     name = game.game_name
     response = self.client.get(url_for('gameName', name = name))
     self.assertEqual(response.status_code, 200)
Beispiel #3
0
    def setUp(self):
        db.session.commit()
        db.drop_all()
        db.create_all()

        update = Lists(first_name="Andre",
                       last_name="Moses",
                       list_title="My List",
                       list_description="description",
                       favourites="PS4")

        addgame = Games(games_id="2", games_title='Mortal Kombat 11')

        newgame = Games(games_id="1",
                        games_title="Ratchet and Clank",
                        age_rating="3",
                        games_price="20",
                        games_description="new game",
                        console_title="PS4")
 def test_repr(self):
     game = Games(game_title='GTA V',
                  description='Gangs',
                  category='Action',
                  age_rating='18')
     print(repr(game))
     review = Reviews(first_name='oskar',
                      last_name='ceremnovas',
                      rating='5',
                      title='review',
                      review='good')
     print(repr(review))
Beispiel #5
0
    def setUp(self):
        db.create_all()
        test_review = Reviews(author="Test author",
                              body="Test body",
                              rating=5,
                              game=1)
        db.session.add(test_review)
        db.session.commit()
        test_game = Games(name="Test game", genre="Test genre")

        db.session.add(test_game)
        db.session.commit()
        app.config['WTF_CSRF_ENABLED'] = False
Beispiel #6
0
def addgame():
    form = GameForm()
    all_games = Games.query.all()
    if request.method == "POST":
        if form.validate_on_submit():
            new_game = Games(name=form.name.data, genre=form.genre.data)
            db.session.add(new_game)
            db.session.commit()
            return redirect(url_for("home"))
    return render_template('addgame.html',
                           title="Add a game",
                           form=form,
                           all_games=all_games)
Beispiel #7
0
def addgame():

    form = GameForm()
    if form.validate_on_submit():
        gameData = Games(game_title=form.game_title.data,
                         description=form.description.data,
                         category=form.category.data,
                         age_rating=form.age_rating.data)
        db.session.add(gameData)
        db.session.commit()

        return redirect(url_for('games'))
    else:
        print(form.errors)

    return render_template('addgame.html', title="Add a Game", form=form)
Beispiel #8
0
 def setUp(self):
     db.create_all()
     test_game = Games(Title="test flask app",
                       Release_date="2020-12-18",
                       Genre="Horror",
                       Age_rating="26",
                       Description="All pain")
     db.session.add(test_game)
     db.session.commit()
     test_review = Reviews(Games_title="test flask app",
                           Review_title="test review table",
                           Reviewer_name="pytest",
                           Review_password="******",
                           Review="I hope I can see this",
                           Rating=10)
     db.session.add(test_review)
     db.session.commit()
Beispiel #9
0
def addgame():
    form = NewGame()
    gameExists = Games.query.filter_by(game_name = form.game.data).first()
    if not gameExists:
        if form.validate_on_submit():
            gameData = Games(
                game_name = form.game.data,
                description = form.description.data
            )
            db.session.add(gameData)
            db.session.commit()
            return redirect(url_for('games'))
        else:
            print(form.errors)
    else:
        print('Game already exists')
        return redirect(url_for('games'))
    return render_template('new_game.html', title='Add Game', form = form, legend = 'New Game')
Beispiel #10
0
def add():
    form = Add()
    if request.method == 'POST':
        new_game = Games(Title=form.Title.data,
                         Release_date=form.Release_date.data,
                         Genre=form.Genre.data,
                         Age_rating=form.Age_rating.data,
                         Description=form.Description.data)
        if not form.validate_on_submit(
        ):  # or new_game.Release_date is None or len(new_game.Title)>300 or len(new_game.Description)>300 or len(new_game.Genre)>30 or len(new_game.Age_rating)>30:
            return render_template('adderror.html',
                                   form=form,
                                   title="New Game")
        else:
            db.session.add(new_game)
            db.session.commit()
            return redirect(url_for("home"))
    return render_template('add.html', form=form, title="New Game")
Beispiel #11
0
def gamesconsoles():
    GamesData = Games.query.all()
    form = GCForm()
    if form.validate_on_submit():
        GamesData = Games(games_title=form.games_title.data,
                          age_rating=form.age_rating.data,
                          games_price=form.games_price.data,
                          games_description=form.games_description.data,
                          console_title=form.console_title.data)
        db.session.add(GamesData)
        db.session.commit()
        return redirect(url_for('gamesconsoles'))

    else:
        print(form.errors)
    return render_template('gamesconsoles.html',
                           title='Games',
                           form=form,
                           games=GamesData)
Beispiel #12
0
def game():
    add_game = AddGameForm()
    if add_game.validate_on_submit():
        add_game_to_db = Games(game_name=add_game.game_name.data,
                               Price=add_game.price.data,
                               company=add_game.company.data,
                               main_platform=add_game.main_platform.data,
                               buyer_id=add_game.buyer_id.data,
                               genre_id=add_game.genre_id.data)
        db.session.add(add_game_to_db)
        db.session.commit()
        return redirect(url_for('game'))
    else:
        print(add_game.errors)
        gameData = Games.query.all()
    return render_template('game.html',
                           title='Game',
                           games=gameData,
                           form=add_game)
Beispiel #13
0
def game():
        add_game = AddGameForm()
        if add_game.validate_on_submit():
                game_reg_id = requests.get('http://service4:5000/catenate_game')
                add_game_to_db = Games(
                                game_name = add_game.game_name.data,
                                Price = add_game.price.data,
                                company = add_game.company.data,
                                main_platform = add_game.main_platform.data,
                                buyer_id = add_game.buyer_id.data,
                                genre_id = add_game.genre_id.data,
                                game_registration_id = game_reg_id.text
                                )
                db.session.add(add_game_to_db)
                db.session.commit()
                app.logger.info(game_reg_id.text)
                return redirect(url_for('game'))
        else:
                print(add_game.errors)
                gameData = Games.query.all()
        return render_template('game.html', title='Game', games=gameData, form=add_game)
    def setUp(self):
        """
        Will be called before every test
        """
        # ensure there is no data in the test database when the test starts
        db.session.commit()
        db.drop_all()
        db.create_all()

        game = Games(game_title='GTA V',
                     description='Gangs',
                     category='Action',
                     age_rating='18')
        # save data to database
        db.session.add(game)
        db.session.commit()
        review = Reviews(first_name='oskar',
                         last_name='ceremnovas',
                         rating='5',
                         title='review',
                         review='good')
        db.session.add(review)
        db.session.commit()
Beispiel #15
0
    def setUp(self):

        #Set up the test driver
        print(
            "--------------------------NEXT-TEST----------------------------------------------"
        )
        chrome_options = Options()
        chrome_options.add_argument("--headless")
        chrome_options.add_argument('--no-sandbox')
        chrome_options.add_argument('--disable-dev-shm-usage')
        self.driver = webdriver.Chrome(chrome_options=chrome_options)
        db.drop_all()
        db.create_all()

        test_game = Games(name="Test game", genre="Test genre")
        test_review = Reviews(author="Test author",
                              body="Test body",
                              rating=5,
                              game=1)
        db.session.add(test_review)
        db.session.add(test_game)
        db.session.commit()
        self.driver.get("http://localhost:5000")

        #Turn off validation
        app.config['WTF_CSRF_ENABLED'] = False

        def tearDown(self):
            self.driver.quit()
            print(
                "--------------------------END-OF-TEST----------------------------------------------\n\n\n-------------------------UNIT-AND-SELENIUM-TESTS----------------------------------------------"
            )

        def test_server_is_up_and_running(self):
            response = urlopen("http://localhost:5000")
            self.assertEqual(response.code, 200)
Beispiel #16
0
from application import db
from application.models import Games

db.drop_all()
db.create_all()
new_game = Games(name="None", genre="None")
db.session.add(new_game)
db.session.commit()
Beispiel #17
0
def add():
    new_game = Games(name="New Game")
    db.session.add(new_game)
    db.session.commit()
    return "Added new game to database"
Beispiel #18
0
from application import db
from application.models import Games

db.drop_all()
db.create_all()

new_game = Games(game="CSGO: ")
db.session.add(new_game)
new_game = Games(game="OSU: ")
db.session.add(new_game)
new_game = Games(game="Fallout 76: ")
db.session.add(new_game)
new_game = Games(game="NieR:Automata: ")
db.session.add(new_game)
new_game = Games(game="GTA V: ")
db.session.add(new_game)
new_game = Games(game="DOOM: ")
db.session.add(new_game)
new_game = Games(game="GTFO: ")
db.session.add(new_game)
new_game = Games(game="Raft: ")
db.session.add(new_game)
db.session.commit()
Beispiel #19
0
def add(game_name):
    new_game = Games(name=game_name)
    db.session.add(new_game)
    db.session.commit()
    return "Added new game to database"
Beispiel #20
0
def add():
    new_game = Games(name="Starcraft")
    db.session.add(new_game)
    db.session.commit()
    return "Added best game to database"