本文整理汇总了Python中mozillians.api.tests.APIAppFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Python APIAppFactory.create方法的具体用法?Python APIAppFactory.create怎么用?Python APIAppFactory.create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mozillians.api.tests.APIAppFactory
的用法示例。
在下文中一共展示了APIAppFactory.create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def setUp(self):
voucher = UserFactory.create()
self.user = UserFactory.create(
userprofile={'is_vouched': True,
'vouched_by': voucher.userprofile})
group = GroupFactory.create()
group.add_member(self.user.userprofile)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
self.user.userprofile.externalaccount_set.create(type=ExternalAccount.TYPE_SUMO,
identifier='Apitest')
self.resource_url = reverse(
'api_dispatch_list',
kwargs={'api_name': 'v1', 'resource_name': 'users'})
self.mozilla_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name,
app_key=self.mozilla_app.key)
self.community_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name,
app_key=self.community_app.key)
示例2: setUp
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def setUp(self):
voucher = UserFactory.create(userprofile={'is_vouched': True})
self.user = UserFactory.create(
userprofile={'is_vouched': True,
'vouched_by': voucher.userprofile})
group = GroupFactory.create()
self.user.userprofile.groups.add(group)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
language = LanguageFactory.create()
self.user.userprofile.languages.add(language)
self.resource_url = reverse(
'api_dispatch_list',
kwargs={'api_name': 'v1', 'resource_name': 'users'})
self.mozilla_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name,
app_key=self.mozilla_app.key)
self.community_app = APIAppFactory.create(
owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name,
app_key=self.community_app.key)
示例3: test_community_app
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def test_community_app(self):
app = APIAppFactory.create(is_mozilla_app=False)
request = RequestFactory()
request.GET = {'app_key': app.key, 'app_name': app.name}
authentication = AppAuthentication()
authentication.is_authenticated(request)
eq_(request.GET.get('restricted'), True)
示例4: setUp
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def setUp(self):
voucher = UserFactory.create(userprofile={"is_vouched": True})
self.user = UserFactory.create(userprofile={"is_vouched": True, "vouched_by": voucher.userprofile})
group = GroupFactory.create()
self.user.userprofile.groups.add(group)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
language = LanguageFactory.create()
self.user.userprofile.languages.add(language)
self.resource_url = reverse("api_dispatch_list", kwargs={"api_name": "v1", "resource_name": "users"})
self.mozilla_app = APIAppFactory.create(owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name, app_key=self.mozilla_app.key
)
self.community_app = APIAppFactory.create(owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name, app_key=self.community_app.key
)
示例5: setUp
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def setUp(self):
voucher = UserFactory.create()
country = CountryFactory()
region = RegionFactory()
city = CityFactory()
self.user = UserFactory.create(
userprofile={"vouched": False, "geo_country": country, "geo_region": region, "geo_city": city}
)
self.user.userprofile.vouch(voucher.userprofile)
group = GroupFactory.create()
group.add_member(self.user.userprofile)
skill = SkillFactory.create()
self.user.userprofile.skills.add(skill)
self.user.userprofile.externalaccount_set.create(type=ExternalAccount.TYPE_SUMO, identifier="Apitest")
self.resource_url = reverse("api_dispatch_list", kwargs={"api_name": "v1", "resource_name": "users"})
self.mozilla_app = APIAppFactory.create(owner=self.user, is_mozilla_app=True)
self.mozilla_resource_url = urlparams(
self.resource_url, app_name=self.mozilla_app.name, app_key=self.mozilla_app.key
)
self.community_app = APIAppFactory.create(owner=self.user, is_mozilla_app=False)
self.community_resource_url = urlparams(
self.resource_url, app_name=self.community_app.name, app_key=self.community_app.key
)
示例6: test_invalid_app_key
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def test_invalid_app_key(self):
app = APIAppFactory.create()
request = RequestFactory()
request.GET = {'app_key': 'invalid', 'app_name': app.name}
authentication = AppAuthentication()
eq_(authentication.is_authenticated(request), False)
示例7: test_empty_app_name
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def test_empty_app_name(self):
app = APIAppFactory.create()
request = RequestFactory()
request.GET = {'app_key': app.key}
authentication = AppAuthentication()
eq_(authentication.is_authenticated(request), False)
示例8: test_valid_app
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def test_valid_app(self):
app = APIAppFactory.create()
request = RequestFactory()
request.GET = {'app_key': app.key, 'app_name': app.name}
authentication = AppAuthentication()
ok_(authentication.is_authenticated(request))
示例9: setUp
# 需要导入模块: from mozillians.api.tests import APIAppFactory [as 别名]
# 或者: from mozillians.api.tests.APIAppFactory import create [as 别名]
def setUp(self):
self.resource_url = reverse("api_dispatch_list", kwargs={"api_name": "v1", "resource_name": "skills"})
self.user = UserFactory.create()
self.app = APIAppFactory.create(owner=self.user, is_mozilla_app=True)
self.resource_url = urlparams(self.resource_url, app_name=self.app.name, app_key=self.app.key)