示例#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
示例#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
示例#3
0
def create_games(amount, users, categories):
    image_game = create_image(name='image', width=256, height=256)
    image_icon = create_image(name='icon', width=48, height=48)
    # TODO: Better titles
    if users and categories:
        for _ in range(amount):
            yield create_game(user=random.choice(users),
                              category=random.choice(categories),
                              title=random.choice(GAME_TITLES),
                              icon=image_icon,
                              image=image_game)
示例#4
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
示例#5
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
示例#6
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
示例#7
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