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


Python Dao.get_excluded_players方法代码示例

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


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

示例1: TestDAO

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

#.........这里部分代码省略.........
        self.dao.delete_player(self.player_2)
        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.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)
开发者ID:novacourtois,项目名称:garpr,代码行数:70,代码来源:test_dao.py


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