def test_instance_creation(): iid = 'instance_create_iid' player = '*****@*****.**' game = Game.get_or_insert(key_name=gid) instance = GameInstance(parent=game, key_name=iid, players=[player], leader=player) assert not instance.full assert not instance.public assert instance.max_players == 0
def test_instance_public(): iid = 'instance_public_iid' player = '*****@*****.**' game = Game.get_or_insert(key_name='public_game') instance = GameInstance(parent=game, key_name=iid, players=[player], leader=player) instance.put() assert instance not in game.get_public_instances_query().fetch(1000) instance.public = True instance.put() public_game = game.get_public_instances_query().fetch(1)[0] assert public_game.to_dictionary() == instance.to_dictionary() instance.public = False instance.put() assert len(game.get_public_instances_query().fetch(1000)) == 0
def test_instance_full(): iid = 'instance_full_iid' player = '*****@*****.**' game = Game.get_or_insert(key_name=gid) instance = GameInstance(parent=game, key_name=iid, players=[player], leader=player) assert not instance.full instance.max_players = 1 assert not instance.full instance.put() assert instance.full instance.max_players = 2 instance.put() assert not instance.full instance.players = [player, '*****@*****.**'] instance.put() assert instance.full instance.max_players = 0 instance.put() assert not instance.full