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


Python Dao.get_players_with_similar_alias方法代码示例

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


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

示例1: TestDAO

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

#.........这里部分代码省略.........
        tournament = tournaments[0]
        self.assertEquals(tournament.id, self.tournament_id_2)
        self.assertEquals(tournament.type, self.tournament_type_2)
        self.assertEquals(tournament.raw, '')
        self.assertEquals(tournament.date, self.tournament_date_2)
        self.assertEquals(tournament.name, self.tournament_name_2)
        self.assertEquals(tournament.matches, self.tournament_matches_2)
        self.assertEquals(tournament.players, self.tournament_players_2)
        self.assertEquals(tournament.regions, self.tournament_regions_2)

    def test_get_tournament_by_id(self):
        tournament_1 = self.norcal_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)
        self.assertEquals(tournament_1.regions, self.tournament_regions_1)

        tournament_2 = self.norcal_dao.get_tournament_by_id(self.tournament_id_2)
        self.assertEquals(tournament_2.id, self.tournament_id_2)
        self.assertEquals(tournament_2.type, self.tournament_type_2)
        self.assertEquals(tournament_2.raw, self.tournament_raw_2)
        self.assertEquals(tournament_2.date, self.tournament_date_2)
        self.assertEquals(tournament_2.name, self.tournament_name_2)
        self.assertEquals(tournament_2.matches, self.tournament_matches_2)
        self.assertEquals(tournament_2.players, self.tournament_players_2)
        self.assertEquals(tournament_2.regions, self.tournament_regions_2)

        self.assertIsNone(self.norcal_dao.get_tournament_by_id(ObjectId()))

    def test_get_players_with_similar_alias(self):
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias('gar'), [self.player_1, self.player_3])
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias('GAR'), [self.player_1, self.player_3])
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias('g a r'), [self.player_1, self.player_3])
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias('garpr | gar'), [self.player_1, self.player_3])

    def test_merge_players(self):
        self.norcal_dao.merge_players(source=self.player_5, target=self.player_1)

        tournament_1 = self.norcal_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)
        self.assertEquals(tournament_1.regions, self.tournament_regions_1)

        tournament_2 = self.norcal_dao.get_tournament_by_id(self.tournament_id_2)
        self.assertEquals(tournament_2.id, self.tournament_id_2)
        self.assertEquals(tournament_2.type, self.tournament_type_2)
        self.assertEquals(tournament_2.raw, self.tournament_raw_2)
        self.assertEquals(tournament_2.date, self.tournament_date_2)
        self.assertEquals(tournament_2.name, self.tournament_name_2)
        self.assertEquals(set(tournament_2.players), set(self.tournament_players_1))
        self.assertEquals(len(tournament_2.matches), len(self.tournament_matches_1))
        self.assertEquals(tournament_2.matches[0], self.tournament_matches_1[0])
        self.assertEquals(tournament_2.matches[1], self.tournament_matches_1[1])
        self.assertEquals(tournament_2.regions, self.tournament_regions_2)

        merged_player_aliases = set(['gar', 'garr', 'pewpewu'])
        merged_player_regions = set(['norcal', 'texas', 'socal'])
开发者ID:MrMonacle,项目名称:garpr,代码行数:70,代码来源:test_dao.py

示例2: TestDAO

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

#.........这里部分代码省略.........

        tournament = tournaments[0]
        self.assertEquals(tournament.id, self.tournament_id_2)
        self.assertEquals(tournament.type, self.tournament_type_2)
        self.assertEquals(tournament.date, self.tournament_date_2)
        self.assertEquals(tournament.name, self.tournament_name_2)
        self.assertEquals(tournament.matches, self.tournament_matches_2)
        self.assertEquals(tournament.players, self.tournament_players_2)
        self.assertEquals(tournament.regions, self.tournament_regions_2)

    def test_get_tournament_by_id(self):
        tournament_1 = self.norcal_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.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)
        self.assertEquals(tournament_1.regions, self.tournament_regions_1)

        tournament_2 = self.norcal_dao.get_tournament_by_id(
            self.tournament_id_2)
        self.assertEquals(tournament_2.id, self.tournament_id_2)
        self.assertEquals(tournament_2.type, self.tournament_type_2)
        self.assertEquals(tournament_2.date, self.tournament_date_2)
        self.assertEquals(tournament_2.name, self.tournament_name_2)
        self.assertEquals(tournament_2.matches, self.tournament_matches_2)
        self.assertEquals(tournament_2.players, self.tournament_players_2)
        self.assertEquals(tournament_2.regions, self.tournament_regions_2)

        self.assertIsNone(self.norcal_dao.get_tournament_by_id(ObjectId()))

    def test_get_players_with_similar_alias(self):
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias(
            'gar'), [self.player_1, self.player_3])
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias(
            'GAR'), [self.player_1, self.player_3])
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias(
            'g a r'), [self.player_1, self.player_3])
        self.assertEquals(self.norcal_dao.get_players_with_similar_alias(
            'garpr | gar'), [self.player_1, self.player_3])

        dao = self.norcal_dao
        self.assertTrue(any(
            player.name == "gaR" for player in dao.get_players_with_similar_alias("1 1 gar")))
        self.assertTrue(any(
            player.name == "gaR" for player in dao.get_players_with_similar_alias("1\t1\tgar")))
        self.assertTrue(any(
            player.name == "gaR" for player in dao.get_players_with_similar_alias("p1s1 gar")))
        self.assertTrue(any(
            player.name == "gaR" for player in dao.get_players_with_similar_alias("GOOG| gar")))
        self.assertTrue(any(
            player.name == "gaR" for player in dao.get_players_with_similar_alias("GOOG | gar")))
        self.assertTrue(any(
            player.name == "gaR" for player in dao.get_players_with_similar_alias("p1s2 GOOG| gar")))
        self.assertTrue(any(player.name == "gaR" for player in dao.get_players_with_similar_alias(
            "garpr goog youtube gar")))

    # TODO: add more tests for merging players
    # this is currently covered by test_get_and_insert_merge
    # def test_merge_players(self):
    #     pass

    def test_merge_players_same_player(self):
        dao = self.norcal_dao
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:70,代码来源:test_dao.py


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