Example #1
0
def test_game_play(client, admin_user):
    category = create_category()
    game = create_game(admin_user, category)

    url = '/games/{game_id}/play'

    # Not logged in
    response = client.get(url.format(game_id=game.id))
    assert response.status_code == 302

    # Login
    client.login(username=admin_user.username, password='******')

    # Game not bought
    response = client.get(url.format(game_id=game.id))
    assert response.status_code == 200

    # Create game sale
    create_game_sale(admin_user, game)

    # Game bought
    response = client.get(url.format(game_id=game.id))
    assert response.status_code == 200

    # Game does not exist
    response = client.get(url.format(game_id=game.id + 1))
    assert response.status_code == 404
Example #2
0
def test_game():
    user = create_user()
    category = create_category()
    image = create_image("image", width=128, height=128)
    icon = create_image("icon", width=48, height=48)
    game = create_game(user, category, icon=icon, image=image)
    assert True
Example #3
0
def test_uploads(client, admin_user):
    category = create_category()
    game = create_game(admin_user, category)
    url = '/uploads/{user_id}'

    # One game published
    response = client.get(url.format(user_id=admin_user.id))
    assert response.status_code == 200

    # No games published / User does not exist
    response = client.get(url.format(user_id=admin_user.id + 1))
    assert response.status_code == 200
Example #4
0
def test_game_detail(client, admin_user):
    category = create_category()
    game = create_game(admin_user, category)
    url = '/games/{game_id}/'

    # Requested game exists
    response = client.get(url.format(game_id=game.id))
    assert response.status_code == 200

    # Requested game does not exist
    response = client.get(url.format(game_id=game.id + 1))
    assert response.status_code == 404
Example #5
0
def test_game_buy(client, admin_user):
    category = create_category()
    game = create_game(admin_user, category)
    url = '/games/{game_id}/buy'

    # Not logged in
    response = client.get(url.format(game_id=game.id))
    assert response.status_code == 302

    # Login
    client.login(username=admin_user.username, password='******')

    # Requested game exists
    response = client.get(url.format(game_id=game.id))
    assert response.status_code == 200

    # Requested game does not exist
    response = client.get(url.format(game_id=game.id + 1))
    assert response.status_code == 404
Example #6
0
def create_user_game():
    user = create_user()
    dev_user = create_user()
    category = create_category("a", "b")
    game = create_game(dev_user, category)
    return game, user