当前位置: 首页>>代码示例>>Python>>正文


Python Dao.update_player_name方法代码示例

本文整理汇总了Python中dao.Dao.update_player_name方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.update_player_name方法的具体用法?Python Dao.update_player_name怎么用?Python Dao.update_player_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在dao.Dao的用法示例。


在下文中一共展示了Dao.update_player_name方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: TestDAO

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import update_player_name [as 别名]

#.........这里部分代码省略.........
        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)))

        self.dao.reset_all_player_ratings()

        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())

    def test_update_tournament(self):
        tournament_1 = self.dao.get_tournament_by_id(self.tournament_id_1)
        self.assertEquals(tournament_1.id, self.tournament_id_1)
        self.assertEquals(tournament_1.type, self.tournament_type_1)
        self.assertEquals(tournament_1.raw, self.tournament_raw_1)
        self.assertEquals(tournament_1.date, self.tournament_date_1)
        self.assertEquals(tournament_1.name, self.tournament_name_1)
        self.assertEquals(tournament_1.matches, self.tournament_matches_1)
        self.assertEquals(tournament_1.players, self.tournament_players_1)
开发者ID:novacourtois,项目名称:garpr,代码行数:69,代码来源:test_dao.py

示例2: TestDAO

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import update_player_name [as 别名]

#.........这里部分代码省略.........
                '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)
        self.assertEquals(pending_tournament_1.name, self.pending_tournament_name_1)
        self.assertEquals(pending_tournament_1.matches, self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament_1.players, self.pending_tournament_players_1)
        self.assertEquals(pending_tournament_1.regions, self.pending_tournament_regions_1)

        pending_tournament_1_raw_new = 'asdfasdf'
        pending_tournament_1_name_new = 'new pending tournament name'

        pending_tournament_1.raw = pending_tournament_1_raw_new
        pending_tournament_1.name = pending_tournament_1_name_new

        self.norcal_dao.update_pending_tournament(pending_tournament_1)

        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)
开发者ID:MrMonacle,项目名称:garpr,代码行数:70,代码来源:test_dao.py

示例3: TestDAO

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import update_player_name [as 别名]

#.........这里部分代码省略.........
        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)
        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_id,
                          self.pending_tournament_raw_id_1)
        self.assertEquals(pending_tournament_1.date,
                          self.pending_tournament_date_1)
        self.assertEquals(pending_tournament_1.name,
                          self.pending_tournament_name_1)
        self.assertEquals(pending_tournament_1.matches,
                          self.pending_tournament_matches_1)
        self.assertEquals(pending_tournament_1.players,
                          self.pending_tournament_players_1)
        self.assertEquals(pending_tournament_1.regions,
                          self.pending_tournament_regions_1)
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:69,代码来源:test_dao.py


注:本文中的dao.Dao.update_player_name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。