本文整理汇总了Python中api.tests.factories.GroupFactory类的典型用法代码示例。如果您正苦于以下问题:Python GroupFactory类的具体用法?Python GroupFactory怎么用?Python GroupFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GroupFactory类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: setUp
def setUp(self):
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.project = ProjectFactory.create(owner=self.group)
self.not_user = UserFactory.create()
self.not_group = GroupFactory.create(name=self.not_user.username)
self.view = ProjectViewSet.as_view({"delete": "destroy"})
self.factory = APIRequestFactory()
self.url = reverse("api:v2:project-detail", args=(self.project.id,))
self.request = self.factory.delete(self.url)
示例2: setUp
def setUp(self):
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.project = ProjectFactory.create(owner=self.group)
user2 = UserFactory.create()
group2 = GroupFactory.create(name=user2.username)
ProjectFactory.create(owner=group2)
self.view = ProjectViewSet.as_view({'get': 'retrieve'})
factory = APIRequestFactory()
url = reverse('api:v2:project-detail', args=(self.project.id,))
self.request = factory.get(url)
示例3: setUp
def setUp(self):
self.view = ViewSet.as_view({'get': 'retrieve'})
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.leadership = LeadershipFactory.create(
user=self.user,
group=self.group
)
self.staff_user = UserFactory.create(is_staff=True)
self.provider = ProviderFactory.create()
self.identity = IdentityFactory.create(
provider=self.provider,
created_by=self.user)
self.quota = QuotaFactory.create()
self.allocation = AllocationFactory.create()
IdentityMembershipFactory.create(
member=self.group,
identity=self.identity,
quota=self.quota
)
factory = APIRequestFactory()
url = reverse('api:v2:identity-detail', args=(self.identity.id,))
self.request = factory.get(url)
force_authenticate(self.request, user=self.user)
self.response = self.view(self.request, pk=self.identity.id)
示例4: setUp
def setUp(self):
self.list_view = ViewSet.as_view({'get': 'list'})
self.detailed_view = ViewSet.as_view({'get': 'retrieve'})
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.staff_user = UserFactory.create(is_staff=True)
self.provider = ProviderFactory.create()
self.quota = QuotaFactory.create()
self.identity = IdentityFactory.create(
provider=self.provider, quota=self.quota, created_by=self.user
)
IdentityMembershipFactory.create(
member=self.group,
identity=self.identity,
)
factory = APIRequestFactory()
detail_url = reverse(
'api:v2:identity-detail', args=(self.identity.id, )
)
self.detail_request = factory.get(detail_url)
list_url = reverse('api:v2:identity-list')
self.list_request = factory.get(list_url)
示例5: setUp
def setUp(self):
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.group.user_set.add(self.user)
self.provider = ProviderFactory.create(location="mock location", type__name="mock")
self.view = TokenUpdateViewSet.as_view({'post': 'create'})
self.identity_view = IdentityViewSet.as_view({'get': 'retrieve'})
self.credentials_view = CredentialViewSet.as_view({'get': 'list'})
self.token_uuid = "test-token-1234-debug"
示例6: setUp
def setUp(self):
self.view = ViewSet.as_view({'get': 'retrieve'})
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.staff_user = UserFactory.create(is_staff=True)
self.quota = QuotaFactory.create()
factory = APIRequestFactory()
url = reverse('api:v2:quota-detail', args=(self.quota.id,))
self.request = factory.get(url)
force_authenticate(self.request, user=self.user)
self.response = self.view(self.request, pk=self.quota.id)
示例7: setUp
def setUp(self):
self.view = ViewSet.as_view({'get': 'list'})
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.staff_user = UserFactory.create(is_staff=True)
self.provider_type = ProviderTypeFactory.create()
factory = APIRequestFactory()
url = reverse('api:v2:providertype-list')
self.request = factory.get(url)
force_authenticate(self.request, user=self.user)
self.response = self.view(self.request)
示例8: setUp
def setUp(self):
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.staff_user = UserFactory.create(is_staff=True)
self.platform_type = PlatformTypeFactory.create()
factory = APIRequestFactory()
self.detail_view = ViewSet.as_view({'get': 'retrieve'})
detail_url = reverse(
self.url_route+'-detail', args=(self.platform_type.id,))
self.detail_request = factory.get(detail_url)
self.list_view = ViewSet.as_view({'get': 'list'})
list_url = reverse(
self.url_route+'-list')
self.list_request = factory.get(list_url)
示例9: setUp
def setUp(self):
self.anonymous_user = AnonymousUserFactory()
self.user = UserFactory.create()
self.group = GroupFactory.create(name=self.user.username)
self.membership = GroupMembershipFactory.create(
user=self.user, group=self.group, is_leader=True
)
self.group.user_set.add(self.user)
self.project = ProjectFactory.create(
owner=self.group, created_by=self.user
)
self.enddated_instance = InstanceFactory.create(
created_by=self.user, end_date=timezone.now(), project=self.project
)
self.user2 = UserFactory.create()
self.group2 = GroupFactory.create(name=self.user2.username)
self.membership2 = GroupMembershipFactory.create(
user=self.user2, group=self.group2, is_leader=True
)
self.group2.user_set.add(self.user2)
self.project2 = ProjectFactory.create(
owner=self.group2, created_by=self.user2
)
self.not_user = UserFactory.create()
self.not_group = GroupFactory.create(name=self.not_user.username)
self.not_membership = GroupMembershipFactory.create(
user=self.not_user, group=self.not_group, is_leader=True
)
self.not_group.user_set.add(self.not_user)
self.not_project = ProjectFactory.create(
owner=self.not_group, created_by=self.not_user
)
self.unsaved_project = ProjectFactory.build(
owner=self.group, created_by=self.user
)
list_url = reverse('api:v2:project-list')
detail_url = reverse('api:v2:project-detail', args=(self.project.id, ))
self.create_view = ProjectViewSet.as_view({'post': 'create'})
self.delete_view = ProjectViewSet.as_view({'delete': 'destroy'})
self.detail_view = ProjectViewSet.as_view({'get': 'retrieve'})
self.list_view = ProjectViewSet.as_view({'get': 'list'})
self.update_view = ProjectViewSet.as_view({'patch': 'partial_update'})
self.factory = APIRequestFactory()
self.bad_create_request = self.factory.post(list_url)
self.create_request = self.factory.post(
list_url, {
'name': self.unsaved_project.name,
'description': self.unsaved_project.description,
'owner': self.group.name
}
)
self.delete_request = self.factory.delete(detail_url)
self.detail_request = self.factory.get(detail_url)
self.list_request = self.factory.get(list_url)
self.updated_project_data = {
'name': 'updated name',
'description': 'updated description'
}
self.update_request = self.factory.patch(
detail_url, self.updated_project_data
)