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


Python Dao.get_all_users方法代码示例

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


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

示例1: TestDAO

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

#.........这里部分代码省略.........
            '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
        all_players = dao.get_all_players()
        player_one = all_players[0]
        user = dao.get_all_users()[0]
        now = datetime.today()

        the_merge = Merge(requester_user_id=user.id,
                          source_player_obj_id=player_one.id,
                          target_player_obj_id=player_one.id,
                          time=now,
                          id=ObjectId())

        with self.assertRaises(ValueError):
            self.norcal_dao.merge_players(the_merge)

    def test_merge_players_in_same_tourney(self):
        dao = self.norcal_dao
        all_players = dao.get_all_players()

        player_one = all_players[0]
        player_two = all_players[1]
        self.assertEqual(player_one.name, u'gaR')
        self.assertEqual(player_two.name, u'sfat')

        user = dao.get_all_users()[0]
        now = datetime.today()
        orig_id = ObjectId()
        the_merge = Merge(requester_user_id=user.id,
                          source_player_obj_id=player_one.id,
                          target_player_obj_id=player_one.id,
                          time=now,
                          id=orig_id)

        with self.assertRaises(ValueError):
            self.norcal_dao.merge_players(the_merge)
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:69,代码来源:test_dao.py

示例2: TestDAO

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

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

    def test_merge_players_none(self):
        with self.assertRaises(TypeError):
            self.norcal_dao.merge_players()

        with self.assertRaises(TypeError):
            self.norcal_dao.merge_players(source=self.player_1)

        with self.assertRaises(TypeError):
            self.norcal_dao.merge_players(target=self.player_1)
    
    def test_merge_players_same_player(self):
        with self.assertRaises(ValueError):
            self.norcal_dao.merge_players(source=self.player_1, target=self.player_1)

    # TODO
    def test_merge_players_same_player_in_single_match(self):
        pass

    def test_get_latest_ranking(self):
        latest_ranking = self.norcal_dao.get_latest_ranking()

        self.assertEquals(latest_ranking.time, self.ranking_time_2)
        self.assertEquals(latest_ranking.tournaments, self.tournament_ids)

        rankings = latest_ranking.ranking
        
        self.assertEquals(len(rankings), 3)
        self.assertEquals(rankings[0], self.ranking_entry_1)
        self.assertEquals(rankings[1], self.ranking_entry_2)
        self.assertEquals(rankings[2], self.ranking_entry_4)

    def test_get_or_create_user_by_id_new_user(self):
        users = self.norcal_dao.get_all_users()
        self.assertEquals(len(users), 2)

        new_id = 'lol'

        user = self.norcal_dao.get_or_create_user_by_id(new_id)
        users = self.norcal_dao.get_all_users()

        self.assertEquals(len(users), 3)

        self.assertEquals(user.id, new_id)
        self.assertEquals(user.full_name, '')
        self.assertEquals(user.admin_regions, [])

        # make sure none of the old users have been modified
        user = users[0]
        self.assertEquals(user.id, self.user_id_1)
        self.assertEquals(user.full_name, '')
        self.assertEquals(user.admin_regions, self.user_admin_regions_1)

        user = users[1]
        self.assertEquals(user.id, self.user_id_2)
        self.assertEquals(user.full_name, self.user_full_name_2)
        self.assertEquals(user.admin_regions, self.user_admin_regions_2)

        user = users[2]
        self.assertEquals(user.id, new_id)
        self.assertEquals(user.full_name, '')
        self.assertEquals(user.admin_regions, [])

    def test_get_or_create_user_by_id_existing_user(self):
        users = self.norcal_dao.get_all_users()
        self.assertEquals(len(users), 2)
开发者ID:MrMonacle,项目名称:garpr,代码行数:70,代码来源:test_dao.py

示例3: Config

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

from pymongo import MongoClient

# add root directory to python path
sys.path.append(os.path.abspath(os.path.dirname(__file__) + '/../'))

from config.config import Config
from dao import Dao

# script to list all users in db
if __name__ == "__main__":
    config = Config()
    mongo_client = MongoClient(host=config.get_mongo_url())
    dao = Dao(None, mongo_client)

    users = dao.get_all_users()
    for user in users:
        print user
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:22,代码来源:list_users.py


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