本文整理汇总了Python中dao.Dao.add_alias_to_player方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.add_alias_to_player方法的具体用法?Python Dao.add_alias_to_player怎么用?Python Dao.add_alias_to_player使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.add_alias_to_player方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: TestDAO
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import add_alias_to_player [as 别名]
#.........这里部分代码省略.........
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)
def test_add_alias_to_player_duplicate(self):
with self.assertRaises(DuplicateAliasException):
self.dao.add_alias_to_player(self.player_1, 'garr')
def test_update_player_name(self):
self.assertEquals(self.dao.get_player_by_id(self.player_1_id).name, 'gaR')
self.assertEquals(self.player_1.name, 'gaR')
self.dao.update_player_name(self.player_1, 'gaRR')
self.assertEquals(self.dao.get_player_by_id(self.player_1_id).name, 'gaRR')
self.assertEquals(self.player_1.name, 'gaRR')
def test_update_player_name_non_alias(self):
with self.assertRaises(InvalidNameException):
self.dao.update_player_name(self.player_1, 'asdf')
def test_reset_all_player_ratings(self):
self.assertEquals(self.dao.get_player_by_id(self.player_1_id).rating, TrueskillRating())
self.assertEquals(self.dao.get_player_by_id(self.player_2_id).rating, TrueskillRating())
self.assertEquals(self.dao.get_player_by_id(self.player_3_id).rating,
TrueskillRating(trueskill_rating=trueskill.Rating(mu=2, sigma=3)))
示例2: TestDAO
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import add_alias_to_player [as 别名]
#.........这里部分代码省略.........
self.norcal_dao.delete_player(self.player_3)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_1_id), self.player_1)
self.assertIsNone(self.norcal_dao.get_player_by_id(self.player_2_id))
self.assertIsNone(self.norcal_dao.get_player_by_id(self.player_3_id))
self.norcal_dao.delete_player(self.player_1)
self.assertIsNone(self.norcal_dao.get_player_by_id(self.player_1_id))
self.assertIsNone(self.norcal_dao.get_player_by_id(self.player_2_id))
self.assertIsNone(self.norcal_dao.get_player_by_id(self.player_3_id))
def test_update_player(self):
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_1_id), self.player_1)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_2_id), self.player_2)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_3_id), self.player_3)
player_1_clone = Player(
'gaR',
['gar', 'garr'],
{'norcal': TrueskillRating(), 'texas': TrueskillRating()},
['norcal', 'texas'],
id=self.player_1_id)
player_1_clone.name = 'garrr'
player_1_clone.aliases.append('garrr')
del player_1_clone.ratings['texas']
self.assertNotEquals(self.norcal_dao.get_player_by_id(self.player_1_id), player_1_clone)
self.norcal_dao.update_player(player_1_clone)
self.assertNotEquals(self.norcal_dao.get_player_by_id(self.player_1_id), self.player_1)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_2_id), self.player_2)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_3_id), self.player_3)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_1_id), player_1_clone)
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.norcal_dao.get_player_by_id(self.player_1_id).aliases, old_expected_aliases)
self.assertEquals(self.player_1.aliases, old_expected_aliases)
self.norcal_dao.add_alias_to_player(self.player_1, new_alias)
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_1_id).aliases, new_expected_aliases)
self.assertEquals(self.player_1.aliases, new_expected_aliases)
def test_add_alias_to_player_duplicate(self):
with self.assertRaises(DuplicateAliasException):
self.norcal_dao.add_alias_to_player(self.player_1, 'garr')
def test_update_player_name(self):
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_1_id).name, 'gaR')
self.assertEquals(self.player_1.name, 'gaR')
self.norcal_dao.update_player_name(self.player_1, 'gaRR')
self.assertEquals(self.norcal_dao.get_player_by_id(self.player_1_id).name, 'gaRR')
self.assertEquals(self.player_1.name, 'gaRR')
def test_update_player_name_non_alias(self):
with self.assertRaises(InvalidNameException):
self.norcal_dao.update_player_name(self.player_1, 'asdf')
def test_update_pending_tournament(self):
pending_tournament_1 = self.norcal_dao.get_pending_tournament_by_id(self.pending_tournament_id_1)
self.assertEquals(pending_tournament_1.id, self.pending_tournament_id_1)
self.assertEquals(pending_tournament_1.type, self.pending_tournament_type_1)
self.assertEquals(pending_tournament_1.raw, self.pending_tournament_raw_1)
self.assertEquals(pending_tournament_1.date, self.pending_tournament_date_1)
示例3: TestDAO
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import add_alias_to_player [as 别名]
#.........这里部分代码省略.........
self.assertIsNone(self.norcal_dao.get_player_by_id(self.player_3_id))
def test_update_player(self):
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_1_id), self.player_1)
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_2_id), self.player_2)
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_3_id), self.player_3)
player_1_clone = Player(
name='gaR',
aliases=['gar', 'garr'],
ratings={'norcal': Rating(), 'texas': Rating()},
regions=['norcal', 'texas'],
id=self.player_1_id)
player_1_clone.name = 'garrr'
player_1_clone.aliases.append('garrr')
del player_1_clone.ratings['texas']
self.assertNotEquals(self.norcal_dao.get_player_by_id(
self.player_1_id), player_1_clone)
self.norcal_dao.update_player(player_1_clone)
self.assertNotEquals(self.norcal_dao.get_player_by_id(
self.player_1_id), self.player_1)
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_2_id), self.player_2)
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_3_id), self.player_3)
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_1_id), player_1_clone)
def test_add_alias_to_player(self):
new_alias = 'gaRRR'
old_expected_aliases = ['gar', 'garr']
new_expected_aliases = ['gar', 'garr', 'garrr']
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_1_id).aliases, old_expected_aliases)
self.assertEquals(self.player_1.aliases, old_expected_aliases)
self.norcal_dao.add_alias_to_player(self.player_1, new_alias)
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_1_id).aliases, new_expected_aliases)
self.assertEquals(self.player_1.aliases, new_expected_aliases)
def test_add_alias_to_player_duplicate(self):
with self.assertRaises(DuplicateAliasException):
self.norcal_dao.add_alias_to_player(self.player_1, 'garr')
def test_update_player_name(self):
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_1_id).name, 'gaR')
self.assertEquals(self.player_1.name, 'gaR')
self.norcal_dao.update_player_name(self.player_1, 'gaRR')
self.assertEquals(self.norcal_dao.get_player_by_id(
self.player_1_id).name, 'gaRR')
self.assertEquals(self.player_1.name, 'gaRR')
def test_update_player_name_non_alias(self):
with self.assertRaises(InvalidNameException):
self.norcal_dao.update_player_name(self.player_1, 'asdf')
def test_update_pending_tournament(self):
pending_tournament_1 = self.norcal_dao.get_pending_tournament_by_id(
self.pending_tournament_id_1)