Ejemplo n.º 1
0
def test_game_details():
    cli = giantbomb_cli()
    test_output_name = cli.game_details('metroid')[0]
    test_output_data = cli.game_details('metroid')[1]
    test_data_string = "Don the Power Suit of intergalactic bounty hunter Samus Aran as she recaptures the dangerous Metroid species from the evil Space Pirates. Released by Nintendo in 1986, this game introduced the \"Metroidvania\" style of open-world gameplay on consoles."
    test_name_string = "Metroid"
    assert test_data_string in test_output_data.get(
        'deck') and test_name_string == test_output_name
Ejemplo n.º 2
0
def main():
    g = giantbomb_cli()
    parser = argparse.ArgumentParser(
        description='CLI interface for the Giantbomb.com API')
    # CLI args
    parser.add_argument('-search',
                        action='store_true',
                        default=False,
                        dest='search_switch',
                        help='Search for a list of games using a search term')
    parser.add_argument('-get-game',
                        action='store_true',
                        default=False,
                        dest='game_switch',
                        help='Get information about a single game')
    parser.add_argument('-get-game-dlc',
                        action='store_true',
                        default=False,
                        dest='dlc_switch',
                        help='Get information about a single game and its dlc')
    parser.add_argument("parameter",
                        action='store',
                        nargs='+',
                        help="Search terms or game name")
    args = parser.parse_args()
    # convert paramaters into list of strings and then into a single string
    params = map(str, args.parameter)
    params = ' '.join(params)

    # cli logic
    if args.search_switch == True:
        g.output_search(g.search(args.parameter))
    elif args.game_switch == True:
        g.output_game(g.game_details(params), False)
    elif args.dlc_switch == True:
        g.output_game(g.game_details(params), True)
    else:
        parser.print_help()
Ejemplo n.º 3
0
def test_search():
    cli = giantbomb_cli()
    assert cli.search('stardew') == {
        'Stardew Valley': 'https://www.giantbomb.com/api/game/3030-50899/'
    }
Ejemplo n.º 4
0
def test_get_dlcs():
    cli = giantbomb_cli()
    test_output = cli.get_dlcs(cli.game_details('Mass Effect'))
    test_output = test_output[0]
    test_string = "In this 253mb downloadable content pack, Shepard and his team are inserted onto a new asteroid and tasked with stopping it from colliding with a planet. It provides about 90 minutes of gameplay."
    assert test_string in test_output.get('deck')
Ejemplo n.º 5
0
def test_output_game(capsys):
    cli = giantbomb_cli()
    test_output = cli.output_game(cli.game_details('Mass Effect'), True)
    test_deck_string = "Humanity is still a newcomer on the futuristic galactic stage, and it's up to the charismatic Commander Shepard to investigate the actions of a rogue agent while under threat from a dangerous synthetic race known as the Geth."
    test_dlc_name = "Pinnacle Station"
    assert test_deck_string and test_dlc_name in capsys.readouterr().out
Ejemplo n.º 6
0
def test_output_search(capsys):
    cli = giantbomb_cli()
    cli.output_search(cli.search('stardew'))
    assert "Stardew Valley" in capsys.readouterr().out