Esempio n. 1
0
def test_dao_create_and_find_player(mongo_database):
    start_date = datetime.now()
    player = Player(name="_Obi", stats={}, games=[], start_date=start_date)
    player_dao = PlayerDao(mongo_database)

    player_id = player_dao.create(player)
    loaded_player = player_dao.find_by_id(player_id)

    assert loaded_player['_id']
    assert "_Obi" == loaded_player['name']
    assert {} == loaded_player['stats']
    assert [] == loaded_player['games']
    assert f'{start_date:%Y-%m-%d %H:%M:%S}' == loaded_player['start_date']
Esempio n. 2
0
def test_dao_create_and_find_players(mongo_database):
    player = Player()
    player_dao = PlayerDao(mongo_database)

    player_dao.create(player)
    player_id = player_dao.create(player)
    loaded_players = player_dao.find_all()

    assert len(loaded_players) > 1
    assert len([player for player in loaded_players if player_id == str(player['_id'])])
Esempio n. 3
0
def test_player_dao_init(mongo_database):
    player_dao = PlayerDao(mongo_database)
    assert mongo_database == player_dao._mongo_database
Esempio n. 4
0
    host = '0.0.0.0'
else:
    port = 5000
    host = '127.0.0.1'

template_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'templates')
static_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'static')

os.environ['FLASK_ENV'] = 'development'

app = Eve(template_folder=template_dir,
          static_folder=static_dir)

board_dao = BoardDao(MongoDatabase())
game_dao = GameDao(MongoDatabase())
player_dao = PlayerDao(MongoDatabase())


# login_doa = LoginDao(MongoDatabase)())
# profile = ProfileDao(MongoDatabase())

@app.route('/hello')
def hello():
    return "Hello Jason!"


# games
@app.route('/chess/game')
def chess_game():
    game = Game()
    return render_template('game.html', game=game)