예제 #1
0
    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.quota = QuotaFactory.create()
        self.identity = IdentityFactory.create(
            provider=self.provider,
            quota=self.quota,
            created_by=self.user)
        self.allocation = AllocationFactory.create()
        IdentityMembershipFactory.create(
            member=self.group,
            identity=self.identity,
        )

        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)
예제 #2
0
 def setUp(self):
     self.anonymous_user = AnonymousUserFactory()
     self.user = UserFactory.create(username='******')
     self.provider = ProviderFactory.create()
     self.user_identity = IdentityFactory.create_identity(
         created_by=self.user,
         provider=self.provider)
     self.group = Group.objects.get(name=self.user)
     self.project = ProjectFactory.create(owner=self.group)
     self.leadership = LeadershipFactory.create(
         user=self.user,
         group=self.group
     )
     self.machine = ProviderMachineFactory.create_provider_machine(self.user, self.user_identity)
     self.active_instance = InstanceFactory.create(name="Instance in active",
                                provider_alias=uuid.uuid4(),
                                source=self.machine.instance_source,
                                created_by=self.user,
                                created_by_identity=self.user_identity,
                                start_date=timezone.now())
     self.project_instances = ProjectInstanceFactory.create(project=self.project, instance=self.active_instance)
     self.view = ProjectInstanceViewSet.as_view({'get': 'list'})
     factory = APIRequestFactory()
     url = reverse('api:v2:projectinstance-list')
     url_proj = "?project__id=" + str(self.project.id)
     url += url_proj
     self.request = factory.get(url)