Пример #1
0
    def setUp(self):
        factory = APIRequestFactory()
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.provider = ProviderFactory.create()
        self.user_identity = IdentityFactory.create_identity(
            created_by=self.user, provider=self.provider
        )
        self.private_image = ImageFactory.create(
            created_by=self.user, private=True
        )
        self.private_version = ApplicationVersionFactory.create_version(
            self.user, self.user_identity, application=self.private_image
        )
        self.private_machine = ProviderMachineFactory.create_provider_machine(
            self.user,
            self.user_identity,
            application=self.private_image,
            version=self.private_version
        )

        self.staff_user = UserFactory.create(is_staff=True)
        self.staff_user_identity = IdentityFactory.create_identity(
            created_by=self.staff_user, provider=self.provider
        )
        self.public_image = ImageFactory.create(
            created_by=self.staff_user, private=False
        )
        self.public_version = ApplicationVersionFactory.create_version(
            self.staff_user,
            self.staff_user_identity,
            application=self.public_image
        )
        self.public_machine = ProviderMachineFactory.create_provider_machine(
            self.staff_user,
            self.staff_user_identity,
            application=self.public_image,
            version=self.public_version
        )

        self.list_view = ViewSet.as_view({'get': 'list'})
        list_url = reverse(self.url_route + '-list')
        self.list_request = factory.get(list_url)

        self.detail_view = ViewSet.as_view({'get': 'retrieve'})
        detail_url = reverse(self.url_route + '-detail', args=(self.user.id, ))
        self.detail_request = factory.get(detail_url)
Пример #2
0
    def setUp(self):
        self.view = ViewSet.as_view({'get': 'retrieve'})
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()

        self.image = ImageFactory.create(created_by=self.user)

        factory = APIRequestFactory()
        url = reverse('api:v2:application-detail', args=(self.user.id,))
        self.request = factory.get(url)
Пример #3
0
    def setUp(self):
        self.view = ViewSet.as_view({'get': 'retrieve'})
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()

        self.image = ImageFactory.create(created_by=self.user)

        factory = APIRequestFactory()
        url = reverse('api:v2:application-detail', args=(self.user.id, ))
        self.request = factory.get(url)
Пример #4
0
    def setUp(self):
        self.view = ViewSet.as_view({'get': 'list'})
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.staff_user = UserFactory.create(is_staff=True)

        self.image = ImageFactory.create(created_by=self.user)

        factory = APIRequestFactory()
        url = reverse('api:v2:application-list')
        self.request = factory.get(url)
        force_authenticate(self.request, user=self.user)
        self.response = self.view(self.request)
Пример #5
0
    def setUp(self):
        self.view = ViewSet.as_view({'get': 'list'})
        self.anonymous_user = AnonymousUserFactory()
        self.user = UserFactory.create()
        self.staff_user = UserFactory.create(is_staff=True)

        self.image = ImageFactory.create(created_by=self.user)

        factory = APIRequestFactory()
        url = reverse('api:v2:application-list')
        self.request = factory.get(url)
        force_authenticate(self.request, user=self.user)
        self.response = self.view(self.request)