本文整理汇总了Python中dao.Dao.get_all_regions方法的典型用法代码示例。如果您正苦于以下问题:Python Dao.get_all_regions方法的具体用法?Python Dao.get_all_regions怎么用?Python Dao.get_all_regions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dao.Dao
的用法示例。
在下文中一共展示了Dao.get_all_regions方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init_with_invalid_region
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_regions [as 别名]
def test_init_with_invalid_region(self):
print Dao.get_all_regions(mongo_client=self.mongo_client)
# create a dao with an existing region
Dao(self.region, mongo_client=self.mongo_client, new=False)
# create a dao with a new region
with self.assertRaises(RegionNotFoundException):
Dao('newregion', mongo_client=self.mongo_client, new=False)
示例2: get
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_regions [as 别名]
def get(self):
regions_dict = {'regions': [r.get_json_dict() for r in Dao.get_all_regions(mongo_client)]}
for region in regions_dict['regions']:
region['id'] = region['_id']
del region['_id']
return regions_dict
示例3: test_get_all_regions
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_regions [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)
示例4: test_get_all_regions
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_regions [as 别名]
def test_get_all_regions(self):
# add another region
region = 'newregion'
Dao(region, mongo_client=self.mongo_client, new=True)
self.assertEquals(set(Dao.get_all_regions(mongo_client=self.mongo_client)), set([self.region, region]))
示例5: ChallongeScraper
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_regions [as 别名]
import unittest
from dao import Dao, RegionNotFoundException, DuplicateAliasException, InvalidNameException
from bson.objectid import ObjectId
from model import *
from ming import mim
import trueskill
from datetime import datetime
from pymongo.errors import DuplicateKeyError
from pymongo import MongoClient
import scraper.challonge
from scraper.challonge import ChallongeScraper
DATABASE_NAME = 'data'
PLAYERS_COLLECTION_NAME = 'players'
TOURNAMENTS_COLLECTION_NAME = 'tournaments'
RANKINGS_COLLECTION_NAME = 'rankings'
REGIONS_COLLECTION_NAME = 'regions'
USERS_COLLECTION_NAME = 'users'
TEST_TOURNEY = 983062
scraper = ChallongeScraper(TEST_TOURNEY)
mongo_client = MongoClient()
region = Region(7,'New Zealand')
##Dao.insert_region(region, mongo_client)
p = Dao.get_all_regions(mongo_client)
mongo_client.close()
示例6: get
# 需要导入模块: from dao import Dao [as 别名]
# 或者: from dao.Dao import get_all_regions [as 别名]
def get(self):
regions_dict = {'regions': [
r.dump(context='web') for r in Dao.get_all_regions(mongo_client)]}
return regions_dict