本文整理汇总了Python中dao.Dao.exclude_player方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.exclude_player方法的具体用法?Python Dao.exclude_player怎么用?Python Dao.exclude_player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.exclude_player方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: bulk_player_exclude
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import exclude_player [as 别名]
def bulk_player_exclude(path, region):
config = parse_config()
username = config.get('database', 'user')
host = config.get('database', 'host')
auth_db = config.get('database', 'auth_db')
password = getpass.getpass()
mongo_client = MongoClient(host='mongodb://%s:%[email protected]%s/%s' % (username, password, host, auth_db))
dao = Dao(region, mongo_client=mongo_client)
with open(path) as f:
for line in f:
line = line.strip()
if line:
db_player = dao.get_player_by_alias(line)
if db_player is None:
raise Exception('%s not found' % line)
print line
dao.exclude_player(db_player)
示例2: TestDAO
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import exclude_player [as 别名]
#.........这里部分代码省略.........
self.assertEquals(self.dao.get_player_by_id(self.player_3_id), self.player_3)
self.dao.delete_player(self.player_3)
self.assertEquals(self.dao.get_player_by_id(self.player_1_id), self.player_1)
self.assertIsNone(self.dao.get_player_by_id(self.player_2_id))
self.assertIsNone(self.dao.get_player_by_id(self.player_3_id))
self.dao.delete_player(self.player_1)
self.assertIsNone(self.dao.get_player_by_id(self.player_1_id))
self.assertIsNone(self.dao.get_player_by_id(self.player_2_id))
self.assertIsNone(self.dao.get_player_by_id(self.player_3_id))
def test_update_player(self):
self.assertEquals(self.dao.get_player_by_id(self.player_1_id), self.player_1)
self.assertEquals(self.dao.get_player_by_id(self.player_2_id), self.player_2)
self.assertEquals(self.dao.get_player_by_id(self.player_3_id), self.player_3)
player_1_clone = Player('gar', ['gar', 'garr'], TrueskillRating(), False, id=self.player_1_id)
player_1_clone.name = 'garrr'
player_1_clone.aliases.append('garrr')
player_1_clone.exclude = True
self.assertNotEquals(self.dao.get_player_by_id(self.player_1_id), player_1_clone)
self.dao.update_player(player_1_clone)
self.assertNotEquals(self.dao.get_player_by_id(self.player_1_id), self.player_1)
self.assertEquals(self.dao.get_player_by_id(self.player_2_id), self.player_2)
self.assertEquals(self.dao.get_player_by_id(self.player_3_id), self.player_3)
self.assertEquals(self.dao.get_player_by_id(self.player_1_id), player_1_clone)
def test_get_excluded_players(self):
self.assertEquals(self.dao.get_excluded_players(), [self.player_3])
def test_exclude_player(self):
self.assertEquals(self.dao.get_excluded_players(), [self.player_3])
self.assertFalse(self.player_1.exclude)
self.dao.exclude_player(self.player_1)
self.assertTrue(self.player_1.exclude)
excluded_players = sorted(self.dao.get_excluded_players(), key=lambda p: p.name)
self.assertEquals(len(excluded_players), 2)
self.assertEquals(excluded_players[0], self.player_1)
self.assertEquals(excluded_players[1], self.player_3)
def test_include_player(self):
self.assertEquals(self.dao.get_excluded_players(), [self.player_3])
self.assertTrue(self.player_3.exclude)
self.dao.include_player(self.player_3)
self.assertFalse(self.player_3.exclude)
self.assertEquals(self.dao.get_excluded_players(), [])
def test_add_alias_to_player(self):
new_alias = 'gaRRR'
lowercase_alias = 'garrr'
old_expected_aliases = ['gar', 'garr']
new_expected_aliases = ['gar', 'garr', 'garrr']
self.assertEquals(self.dao.get_player_by_id(self.player_1_id).aliases, old_expected_aliases)
self.assertEquals(self.player_1.aliases, old_expected_aliases)
self.dao.add_alias_to_player(self.player_1, new_alias)
self.assertEquals(self.dao.get_player_by_id(self.player_1_id).aliases, new_expected_aliases)
self.assertEquals(self.player_1.aliases, new_expected_aliases)