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


Python Dao.insert_region方法代码示例

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


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

示例1: setUp

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_region [as 别名]
    def setUp(self):
        self.mongo_client_patcher = patch('server.mongo_client', new=mongomock.MongoClient())
        self.mongo_client = self.mongo_client_patcher.start()

        server.app.config['TESTING'] = True
        self.app = server.app.test_client()

        self.norcal_region = Region('norcal', 'Norcal')
        self.texas_region = Region('texas', 'Texas')
        Dao.insert_region(self.norcal_region, self.mongo_client)
        Dao.insert_region(self.texas_region, self.mongo_client)

        self.norcal_dao = Dao(NORCAL_REGION_NAME, mongo_client=self.mongo_client)
        self.texas_dao = Dao(TEXAS_REGION_NAME, mongo_client=self.mongo_client)

        self._import_files()

        now = datetime(2014, 11, 1)
        rankings.generate_ranking(self.norcal_dao, now=now)
        rankings.generate_ranking(self.texas_dao, now=now)

        self.user_id = 'asdf'
        self.user_full_name = 'full name'
        self.user_admin_regions = ['norcal', 'nyc']
        self.user = User(self.user_id, self.user_admin_regions, full_name=self.user_full_name)
        self.norcal_dao.insert_user(self.user)
开发者ID:AJAnderson,项目名称:garpr,代码行数:28,代码来源:test_server.py

示例2: test_get_all_regions

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_region [as 别名]
    def test_get_all_regions(self):
        # add another region
        region = Region('newregion', 'New Region')
        Dao.insert_region(region, self.mongo_client, database_name=DATABASE_NAME)

        regions = Dao.get_all_regions(self.mongo_client, database_name=DATABASE_NAME)
        self.assertEquals(len(regions), 3)
        self.assertEquals(regions[0], region)
        self.assertEquals(regions[1], self.region_1)
        self.assertEquals(regions[2], self.region_2)
开发者ID:MrMonacle,项目名称:garpr,代码行数:12,代码来源:test_dao.py

示例3: setUp

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_region [as 别名]
    def setUp(self):
        self.maxDiff = None

        self.player_1_id = ObjectId()
        self.player_2_id = ObjectId()
        self.player_3_id = ObjectId()
        self.player_4_id = ObjectId()
        self.player_5_id = ObjectId()
        self.player_1 = Player(
                name='gaR',
                aliases=['gar', 'garr'],
                ratings={'norcal': Rating(), 'texas': Rating()},
                regions=['norcal', 'texas'],
                id=self.player_1_id)
        self.player_2 = Player(
                name='sfat',
                aliases=['sfat', 'miom | sfat'],
                ratings={'norcal': Rating()},
                regions=['norcal'],
                id=self.player_2_id)
        self.player_3 = Player(
                name='mango',
                aliases=['mango', 'gar'],
                ratings={'norcal': Rating(mu=2, sigma=3)},
                regions=['socal'],
                id=self.player_3_id)
        self.player_4 = Player(
                name='garpr|gar',
                aliases=['garpr|gar'],
                ratings={'norcal': Rating(mu=2, sigma=3)},
                regions=['norcal'],
                id=self.player_4_id)

        self.players = [self.player_1, self.player_2, self.player_3, self.player_4]

        self.user_id_1 = 'abc123'
        self.user_admin_regions_1 = ['norcal']
        self.username1 = 'Full Name'
        #    def __init__(self, id, admin_regions, username, salt, hashed_password):
        self.user_1 = User(id=self.user_id_1,
                           admin_regions=self.user_admin_regions_1,
                           username=self.username1,
                           salt='nacl',
                           hashed_password='browns')

        self.users = [self.user_1]

        self.region_1 = Region(id='norcal', display_name='Norcal')
        Dao.insert_region(self.region_1, self.mongo_client, database_name=DATABASE_NAME)
        self.norcal_dao = Dao('norcal', self.mongo_client, database_name=DATABASE_NAME)

        for player in self.players:
            self.norcal_dao.insert_player(player)
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:55,代码来源:test_alias_service.py

示例4: setUp

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_region [as 别名]
    def setUp(self):
        self.maxDiff = None
        self.mongo_client = MongoClient()

        self.player_1_id = ObjectId()
        self.player_2_id = ObjectId()
        self.player_3_id = ObjectId()
        self.player_4_id = ObjectId()
        self.player_5_id = ObjectId()
        self.player_1 = Player(
                'gaR', 
                ['gar', 'garr'], 
                {'norcal': TrueskillRating(), 'texas': TrueskillRating()}, 
                ['norcal', 'texas'], 
                id=self.player_1_id)
        self.player_2 = Player(
                'sfat', 
                ['sfat', 'miom | sfat'], 
                {'norcal': TrueskillRating()}, 
                ['norcal'], 
                id=self.player_2_id)
        self.player_3 = Player(
                'mango', 
                ['mango', 'gar'], 
                {'norcal': TrueskillRating(trueskill_rating=trueskill.Rating(mu=2, sigma=3))}, 
                ['socal'], 
                id=self.player_3_id)
        self.player_4 = Player(
                'garpr|gar', 
                ['garpr|gar'], 
                {'norcal': TrueskillRating(trueskill_rating=trueskill.Rating(mu=2, sigma=3))}, 
                ['norcal'], 
                id=self.player_4_id)

        self.players = [self.player_1, self.player_2, self.player_3, self.player_4]

        self.user_id_1 = 'abc123'
        self.user_full_name_1 = 'Full Name'
        self.user_admin_regions_1 = ['norcal']
        self.user_1 = User(self.user_id_1, self.user_admin_regions_1, full_name=self.user_full_name_1)

        self.users = [self.user_1]

        self.region_1 = Region('norcal', 'Norcal')
        Dao.insert_region(self.region_1, self.mongo_client, database_name=DATABASE_NAME)
        self.norcal_dao = Dao('norcal', self.mongo_client, database_name=DATABASE_NAME)

        for player in self.players:
            self.norcal_dao.insert_player(player)

        for user in self.users:
            self.norcal_dao.insert_user(user)
开发者ID:MrMonacle,项目名称:garpr,代码行数:54,代码来源:test_alias_service.py

示例5: setUp

# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import insert_region [as 别名]
    def setUp(self):
        self.region_id = 'norcal'
        self.region = Region(id=self.region_id,
                             display_name='Norcal')

        self.mongo_client = mongomock.MongoClient()
        Dao.insert_region(self.region, self.mongo_client)

        self.dao = Dao(self.region_id, mongo_client=self.mongo_client)

        self.player_1_id = ObjectId()
        self.player_2_id = ObjectId()
        self.player_3_id = ObjectId()
        self.player_4_id = ObjectId()
        self.player_5_id = ObjectId()
        self.player_1 = Player(
                name='gaR',
                aliases=['gar', 'garr'],
                ratings={'norcal': Rating(), 'texas': Rating()},
                regions=['norcal', 'texas'],
                id=self.player_1_id)
        self.player_2 = Player(
                name='sfat',
                aliases=['sfat', 'miom | sfat'],
                ratings={'norcal': Rating()},
                regions=['norcal'],
                id=self.player_2_id)
        self.player_3 = Player(
                name='mango',
                aliases=['mango'],
                ratings={'norcal': Rating(mu=2, sigma=3)},
                regions=['socal'],
                id=self.player_3_id)
        self.player_4 = Player(
                name='shroomed',
                aliases=['shroomed'],
                ratings={'norcal': Rating()},
                regions=['norcal'],
                id=self.player_4_id)
        self.player_5 = Player(
                name='pewpewu',
                aliases=['pewpewu'],
                ratings={'norcal': Rating()},
                regions=['norcal'],
                id=self.player_5_id)

        self.players = [self.player_1, self.player_2, self.player_3, self.player_4, self.player_5]

        self.tournament_id_1 = ObjectId()
        self.tournament_type_1 = 'tio'
        self.tournament_raw_1 = 'raw1'
        self.tournament_date_1 = datetime(2013, 10, 16)
        self.tournament_name_1 = 'tournament 1'
        self.tournament_players_1 = [self.player_1_id, self.player_2_id, self.player_3_id, self.player_4_id]
        self.tournament_matches_1 = [
                Match(winner=self.player_1_id, loser=self.player_2_id),
                Match(winner=self.player_3_id, loser=self.player_4_id)
        ]
        self.tournament_regions_1 = ['norcal']

        # tournament 2 is earlier than tournament 1, but inserted after
        self.tournament_id_2 = ObjectId()
        self.tournament_type_2 = 'challonge'
        self.tournament_raw_2 = 'raw2'
        self.tournament_date_2 = datetime(2013, 10, 10)
        self.tournament_name_2 = 'tournament 2'
        self.tournament_players_2 = [self.player_5_id, self.player_2_id, self.player_3_id, self.player_4_id]
        self.tournament_matches_2 = [
                Match(winner=self.player_5_id, loser=self.player_2_id),
                Match(winner=self.player_3_id, loser=self.player_4_id)
        ]
        self.tournament_regions_2 = ['norcal', 'texas']

        self.tournament_1 = Tournament(
                    type=self.tournament_type_1,
                    raw=self.tournament_raw_1,
                    date=self.tournament_date_1,
                    name=self.tournament_name_1,
                    players=self.tournament_players_1,
                    matches=self.tournament_matches_1,
                    regions=self.tournament_regions_1,
                    id=self.tournament_id_1)

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

        self.tournament_ids = [self.tournament_id_1, self.tournament_id_2]
        self.tournaments = [self.tournament_1, self.tournament_2]

        for player in self.players:
            self.dao.insert_player(player)

        for tournament in self.tournaments:
#.........这里部分代码省略.........
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:103,代码来源:test_rankings.py

示例6: setUp

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

#.........这里部分代码省略.........
                MatchResult(winner=self.player_5_id, loser=self.player_2_id),
                MatchResult(winner=self.player_3_id, loser=self.player_4_id)
        ]
        self.tournament_regions_2 = ['norcal', 'texas']

        self.tournament_1 = Tournament(self.tournament_type_1,
                                       self.tournament_raw_1,
                                       self.tournament_date_1, 
                                       self.tournament_name_1,
                                       self.tournament_players_1,
                                       self.tournament_matches_1,
                                       self.tournament_regions_1,
                                       id=self.tournament_id_1)

        self.tournament_2 = Tournament(self.tournament_type_2,
                                       self.tournament_raw_2,
                                       self.tournament_date_2, 
                                       self.tournament_name_2,
                                       self.tournament_players_2,
                                       self.tournament_matches_2,
                                       self.tournament_regions_2,
                                       id=self.tournament_id_2)

        self.tournament_ids = [self.tournament_id_1, self.tournament_id_2]
        self.tournaments = [self.tournament_1, self.tournament_2]

        self.pending_tournament_id_1 = ObjectId()
        self.pending_tournament_type_1 = 'tio'
        self.pending_tournament_raw_1 = 'raw1'
        self.pending_tournament_date_1 = datetime(2013, 10, 11)
        self.pending_tournament_name_1 = 'pending tournament 1'
        self.pending_tournament_players_1 = [self.player_1.name, self.player_2.name, self.player_3.name, self.player_4.name]
        self.pending_tournament_matches_1 = [
                MatchResult(winner=self.player_1.name, loser=self.player_2.name),
                MatchResult(winner=self.player_3.name, loser=self.player_4.name)
        ]
        self.pending_tournament_regions_1 = ['norcal']

        self.pending_tournament_1 = PendingTournament(self.pending_tournament_type_1,
                                                      self.pending_tournament_raw_1,
                                                      self.pending_tournament_date_1, 
                                                      self.pending_tournament_name_1,
                                                      self.pending_tournament_players_1,
                                                      self.pending_tournament_matches_1,
                                                      self.pending_tournament_regions_1,
                                                      id=self.pending_tournament_id_1)

        self.pending_tournaments = [self.pending_tournament_1]

        self.ranking_entry_1 = RankingEntry(1, self.player_1_id, 20)
        self.ranking_entry_2 = RankingEntry(2, self.player_2_id, 19)
        self.ranking_entry_3 = RankingEntry(3, self.player_3_id, 17.5)
        self.ranking_entry_4 = RankingEntry(3, self.player_4_id, 16.5)

        self.ranking_time_1 = datetime(2013, 4, 20)
        self.ranking_time_2 = datetime(2013, 4, 21)
        self.ranking_1 = Ranking('norcal', self.ranking_time_1, self.tournament_ids, 
                                 [self.ranking_entry_1, self.ranking_entry_2, self.ranking_entry_3])
        self.ranking_2 = Ranking('norcal', self.ranking_time_2, self.tournament_ids, 
                                 [self.ranking_entry_1, self.ranking_entry_2, self.ranking_entry_4])
        self.ranking_3 = Ranking('texas', self.ranking_time_2, self.tournament_ids, 
                                 [self.ranking_entry_1, self.ranking_entry_2])

        self.rankings = [self.ranking_1, self.ranking_2, self.ranking_3]

        self.user_id_1 = 'abc123'
        self.user_admin_regions_1 = ['norcal', 'texas']
        self.user_1 = User(self.user_id_1, self.user_admin_regions_1)

        self.user_id_2 = 'asdfasdf'
        self.user_full_name_2 = 'Full Name'
        self.user_admin_regions_2 = []
        self.user_2 = User(self.user_id_2, self.user_admin_regions_2, full_name=self.user_full_name_2)

        self.users = [self.user_1, self.user_2]

        self.region_1 = Region('norcal', 'Norcal')
        self.region_2 = Region('texas', 'Texas')

        self.regions = [self.region_1, self.region_2]

        for region in self.regions:
            Dao.insert_region(region, self.mongo_client, database_name=DATABASE_NAME)

        self.norcal_dao = Dao('norcal', self.mongo_client, database_name=DATABASE_NAME)

        for player in self.players:
            self.norcal_dao.insert_player(player)

        for tournament in self.tournaments:
            self.norcal_dao.insert_tournament(tournament)

        for pending_tournament in self.pending_tournaments:
            self.norcal_dao.insert_pending_tournament(pending_tournament)

        for ranking in self.rankings:
            self.norcal_dao.insert_ranking(ranking)

        for user in self.users:
            self.norcal_dao.insert_user(user)
开发者ID:MrMonacle,项目名称:garpr,代码行数:104,代码来源:test_dao.py

示例7: setUp

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

#.........这里部分代码省略.........
            type=self.pending_tournament_type_1,
            date=self.pending_tournament_date_1,
            regions=self.pending_tournament_regions_1,
            raw_id=self.pending_tournament_raw_id_1,
            players=self.pending_tournament_players_1,
            matches=self.pending_tournament_matches_1)

        self.pending_tournaments = [self.pending_tournament_1]

        self.ranking_entry_1 = RankingEntry(
            rank=1, player=self.player_1_id, rating=20)
        self.ranking_entry_2 = RankingEntry(
            rank=2, player=self.player_2_id, rating=19)
        self.ranking_entry_3 = RankingEntry(
            rank=3, player=self.player_3_id, rating=17.5)
        self.ranking_entry_4 = RankingEntry(
            rank=3, player=self.player_4_id, rating=16.5)

        self.ranking_time_1 = datetime(2013, 4, 20)
        self.ranking_time_2 = datetime(2013, 4, 21)
        self.ranking_1 = Ranking(
            id=ObjectId(),
            region='norcal',
            time=self.ranking_time_1,
            tournaments=self.tournament_ids,
            ranking=[self.ranking_entry_1, self.ranking_entry_2, self.ranking_entry_3])
        self.ranking_2 = Ranking(
            id=ObjectId(),
            region='norcal',
            time=self.ranking_time_2,
            tournaments=self.tournament_ids,
            ranking=[self.ranking_entry_1, self.ranking_entry_2, self.ranking_entry_4])
        self.ranking_3 = Ranking(
            id=ObjectId(),
            region='norcal',
            time=self.ranking_time_2,
            tournaments=self.tournament_ids,
            ranking=[self.ranking_entry_1, self.ranking_entry_2])

        self.rankings = [self.ranking_1, self.ranking_2, self.ranking_3]

        self.user_id_1 = 'abc123'
        self.user_admin_regions_1 = ['norcal', 'texas']
        self.user_1 = User(id=self.user_id_1,
                           admin_regions=self.user_admin_regions_1,
                           username='user1',
                           salt='nacl',
                           hashed_password='browns',
                           admin_level='REGION')

        self.user_id_2 = 'asdfasdf'
        self.user_full_name_2 = 'Full Name'
        self.user_admin_regions_2 = []
        self.user_2 = User(id=self.user_id_2,
                           admin_regions=self.user_admin_regions_2,
                           username=self.user_full_name_2,
                           salt='nacl',
                           hashed_password='browns',
                           admin_level='REGION')

        self.superadmin_id = '123456'
        self.superadmin_full_name = 'superadmin'
        self.superadmin_admin_regions = []
        self.superadmin = User(
            id=self.superadmin_id,
            user_admin_regions=self.superadmin_admin_regions,
            username=self.superadmin_full_name,
            salt='nacl',
            hashed_password='browns',
            admin_level='SUPER'
        )

        self.users = [self.user_1, self.user_2, self.superadmin]

        self.region_1 = Region(id='norcal', display_name='Norcal')
        self.region_2 = Region(id='texas', display_name='Texas')

        self.regions = [self.region_1, self.region_2]

        for region in self.regions:
            Dao.insert_region(region, self.mongo_client,
                              database_name=DATABASE_NAME)

        self.norcal_dao = Dao('norcal', self.mongo_client,
                              database_name=DATABASE_NAME)

        for player in self.players:
            self.norcal_dao.insert_player(player)

        for tournament in self.tournaments:
            self.norcal_dao.insert_tournament(tournament)

        for pending_tournament in self.pending_tournaments:
            self.norcal_dao.insert_pending_tournament(pending_tournament)

        for ranking in self.rankings:
            self.norcal_dao.insert_ranking(ranking)

        for user in self.users:
            self.norcal_dao.insert_user(user)
开发者ID:BrandonCookeDev,项目名称:garpr,代码行数:104,代码来源:test_dao.py


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