Ejemplo n.º 1
0
    def setUp(self):
        self.profile = ProfileFactory()
        self.other = ProfileFactory()
        self.new_participant = ProfileFactory()
        self.client = APIClient()
        client_oauth2 = create_oauth2_client(self.profile.user)
        authenticate_client(self.client, client_oauth2,
                            self.profile.user.username, 'hostel77')

        self.gallery = GalleryFactory()
        UserGalleryFactory(user=self.profile.user, gallery=self.gallery)
        self.image = ImageFactory(gallery=self.gallery)

        self.gallery_other = GalleryFactory()
        UserGalleryFactory(user=self.other.user, gallery=self.gallery_other)
        self.image_other = ImageFactory(gallery=self.gallery_other)

        self.gallery_shared = GalleryFactory()
        UserGalleryFactory(user=self.other.user, gallery=self.gallery_shared)
        UserGalleryFactory(user=self.profile.user,
                           gallery=self.gallery_shared,
                           mode=GALLERY_READ)
        self.image_shared = ImageFactory(gallery=self.gallery_shared)

        tuto = PublishableContentFactory(
            type='TUTORIAL',
            author_list=[self.profile.user, self.new_participant.user])
        self.gallery_tuto = tuto.gallery
Ejemplo n.º 2
0
 def setUp(self):
     self.profile = ProfileFactory()
     self.client = APIClient()
     client_oauth2 = create_oauth2_client(self.profile.user)
     authenticate_client(self.client, client_oauth2,
                         self.profile.user.username, 'hostel77')
     caches[extensions_api_settings.DEFAULT_USE_CACHE].clear()
Ejemplo n.º 3
0
    def setUp(self):
        self.profile = ProfileFactory()
        self.client = APIClient()
        client_oauth2 = create_oauth2_client(self.profile.user)
        authenticate_client(self.client, client_oauth2,
                            self.profile.user.username, 'hostel77')

        self.another_profile = ProfileFactory()
        self.another_client = APIClient()
        another_client_oauth2 = create_oauth2_client(self.another_profile.user)
        authenticate_client(self.another_client, another_client_oauth2,
                            self.another_profile.user.username, 'hostel77')

        self.bot_group = Group()
        self.bot_group.name = ZDS_APP["member"]["bot_group"]
        self.bot_group.save()

        get_cache(extensions_api_settings.DEFAULT_USE_CACHE).clear()
Ejemplo n.º 4
0
    def setUp(self):
        self.profile = ProfileFactory()
        self.client = APIClient()
        client_oauth2 = create_oauth2_client(self.profile.user)
        authenticate_client(self.client, client_oauth2,
                            self.profile.user.username, 'hostel77')

        self.private_topic = PrivateTopicFactory(author=self.profile.user)

        get_cache(extensions_api_settings.DEFAULT_USE_CACHE).clear()
Ejemplo n.º 5
0
    def setUp(self):
        self.profile = ProfileFactory()
        self.other = ProfileFactory()
        self.client = APIClient()
        client_oauth2 = create_oauth2_client(self.profile.user)
        authenticate_client(self.client, client_oauth2, self.profile.user.username, 'hostel77')

        self.gallery = GalleryFactory()

        tuto = PublishableContentFactory(type='TUTORIAL', author_list=[self.profile.user])
        self.gallery_tuto = tuto.gallery

        caches[extensions_api_settings.DEFAULT_USE_CACHE].clear()
Ejemplo n.º 6
0
    def setUp(self):
        self.profile = ProfileFactory()
        self.private_topic = PrivateTopicFactory(author=self.profile.user)
        self.private_post = PrivatePostFactory(author=self.profile.user,
                                               privatetopic=self.private_topic,
                                               position_in_topic=1)
        self.client = APIClient()
        client_oauth2 = create_oauth2_client(self.profile.user)
        authenticate_client(self.client, client_oauth2,
                            self.profile.user.username, 'hostel77')

        self.bot_group = Group()
        self.bot_group.name = ZDS_APP["member"]["bot_group"]
        self.bot_group.save()

        get_cache(extensions_api_settings.DEFAULT_USE_CACHE).clear()
Ejemplo n.º 7
0
    def test_update_private_topic_with_user_not_author(self):
        """
        Gets an error 403 when we try to update a private topic when we aren't the author.
        """
        another_profile = ProfileFactory()
        self.private_topic.participants.add(another_profile.user)

        self.client = APIClient()
        client_oauth2 = create_oauth2_client(another_profile.user)
        authenticate_client(self.client, client_oauth2,
                            another_profile.user.username, 'hostel77')

        data = {
            'title': 'Good title',
        }
        response = self.client.put(
            reverse('api-mp-detail', args=[self.private_topic.id]), data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)
Ejemplo n.º 8
0
    def setUp(self):
        self.profile = ProfileFactory()
        self.other = ProfileFactory()
        self.client = APIClient()
        client_oauth2 = create_oauth2_client(self.profile.user)
        authenticate_client(self.client, client_oauth2, self.profile.user.username, 'hostel77')

        self.gallery = GalleryFactory()
        UserGalleryFactory(user=self.profile.user, gallery=self.gallery)
        self.image = ImageFactory(gallery=self.gallery)

        self.gallery_other = GalleryFactory()
        UserGalleryFactory(user=self.other.user, gallery=self.gallery_other)
        self.image_other = ImageFactory(gallery=self.gallery_other)

        self.gallery_shared = GalleryFactory()
        UserGalleryFactory(user=self.other.user, gallery=self.gallery_shared)
        UserGalleryFactory(user=self.profile.user, gallery=self.gallery_shared, mode=GALLERY_READ)
        self.image_shared = ImageFactory(gallery=self.gallery_shared)
Ejemplo n.º 9
0
    def test_add_participant_with_an_user_not_author_of_private_topic(self):
        """
        Gets an error 403 when we try to update participants of a private topic without to be the author but in
        participants.
        """
        another_profile = ProfileFactory()
        third_profile = ProfileFactory()
        self.private_topic.participants.add(another_profile.user)

        self.client = APIClient()
        client_oauth2 = create_oauth2_client(another_profile.user)
        authenticate_client(self.client, client_oauth2,
                            another_profile.user.username, 'hostel77')

        data = {
            'participants': third_profile.user.id,
        }
        response = self.client.put(
            reverse('api-mp-detail', args=[self.private_topic.id]), data)
        self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)