Ejemplo n.º 1
0
    def test_update_sub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        post_data = {'name': "", 'description': "changed description"}
        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_update', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 400)

        post_data = {'name': "changed name", 'description': ""}
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_update', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 400)

        post_data = {
            'name': "changed name",
            'description': "changed description"
        }
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_update', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id=folder.id)
        self.assertEqual(folder.name, "changed name")
        self.assertEqual(folder.description, "changed description")
Ejemplo n.º 2
0
    def test_remove_user_unsub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.users.add(self.subscribed_user_2)

        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_remove_user',
            kwargs={
                'pk': folder.id,
                'user_id': self.subscribed_user_2.id
            }), {},
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest',
                                    follow=True)
        self.assertRedirects(
            response,
            reverse('rawdata.restricted') + '?' + urlencode({
                'next':
                '/rawdata/privatesharedfolders/%d/remove-user/%d/' %
                (folder.id, self.subscribed_user_2.id)
            }),
            status_code=302,
            target_status_code=200)
        self.client.logout()
Ejemplo n.º 3
0
    def test_update_sub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        post_data = {'name': "", 'description': "changed description"}
        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 400)

        post_data = {'name': "changed name", 'description': ""}
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 400)

        post_data = {'name': "changed name", 'description': "changed description"}
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id = folder.id)
        self.assertEqual(folder.name, "changed name")
        self.assertEqual(folder.description, "changed description")
Ejemplo n.º 4
0
    def test_detail_sub_uninvited(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        self.client.login(username='******', password='******')
        response = self.client.get(
            reverse('rawdata.privatesharedfolder_detail', args=(folder.id, )))
        self.assertEqual(response.status_code, 404)
        self.client.logout()
Ejemplo n.º 5
0
    def test_detail_sub_uninvited(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        self.client.login(username = '******', password = '******')
        response = self.client.get(
            reverse('rawdata.privatesharedfolder_detail', args = (folder.id,)))
        self.assertEqual(response.status_code, 404)
        self.client.logout()
Ejemplo n.º 6
0
    def test_detail_anon(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        response = self.client.get(
            reverse('rawdata.privatesharedfolder_detail', args = (folder.id,)),
            follow = True)
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/' % folder.id,
            status_code = 302, target_status_code = 200)
Ejemplo n.º 7
0
    def test_update_unsub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        self.client.login(username = '******', password = '******')
        post_data = {'name': "changed name", 'description': "changed description"}
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args = (folder.id,)),
            post_data)
        self.assertEqual(response.status_code, 404)
        self.client.logout()
Ejemplo n.º 8
0
    def test_download_wrong_sub(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        self.client.login(username = '******', password = '******')
        response = self.client.get(reverse('rawdata.privatesharedfolder_download', args = (folder.id,)), follow = True)
        self.assertEqual(response.status_code, 404)
Ejemplo n.º 9
0
    def test_download_wrong_sub(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        self.client.login(username='******', password='******')
        response = self.client.get(reverse(
            'rawdata.privatesharedfolder_download', args=(folder.id, )),
                                   follow=True)
        self.assertEqual(response.status_code, 404)
Ejemplo n.º 10
0
    def test_update_anon(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        post_data = {'name': "changed name", 'description': "changed description"}
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args = (folder.id,)),
            post_data)
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/update/' % folder.id,
            status_code = 302, target_status_code = 200)
Ejemplo n.º 11
0
    def test_add_users_anon(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        post_data = {'users': self.subscribed_user_2}
        response = self.client.post(reverse('rawdata.privatesharedfolder_add_users', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/add-users/' % folder.id,
            status_code = 302, target_status_code = 200)
Ejemplo n.º 12
0
    def test_detail_anon(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        response = self.client.get(reverse(
            'rawdata.privatesharedfolder_detail', args=(folder.id, )),
                                   follow=True)
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/'
            % folder.id,
            status_code=302,
            target_status_code=200)
Ejemplo n.º 13
0
    def test_update_unsub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        self.client.login(username='******', password='******')
        post_data = {
            'name': "changed name",
            'description': "changed description"
        }
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args=(folder.id, )),
            post_data)
        self.assertEqual(response.status_code, 404)
        self.client.logout()
Ejemplo n.º 14
0
    def test_add_users_sub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        post_data = {'users': self.subscribed_user_2}
        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_add_users', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id=folder.id)
        self.assertEqual(folder.users.all().count(), 1)
Ejemplo n.º 15
0
    def test_delete_sub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        self.client.login(username='******', password='******')
        response = self.client.delete(reverse(
            'rawdata.privatesharedfolder_delete', args=(folder.id, )),
                                      HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 200)

        self.client.logout()

        count = PrivateSharedFolder.objects.filter(id=folder.id).count()
        self.assertEqual(count, 0)
Ejemplo n.º 16
0
    def test_delete_anon(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        response = self.client.delete(
            reverse('rawdata.privatesharedfolder_delete', args = (folder.id,)))
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/delete/' % folder.id,
            status_code = 302, target_status_code = 200)

        count = PrivateSharedFolder.objects.filter(id = folder.id).count()
        self.assertEqual(count, 1)
Ejemplo n.º 17
0
    def test_download_anon(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        response = self.client.get(reverse('rawdata.privatesharedfolder_download', args = (folder.id,)))
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/download/' % folder.id,
            status_code = 302, target_status_code = 200)
Ejemplo n.º 18
0
    def test_add_users_multi_sub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        post_data = {'users': "%s,%s" % (self.subscribed_user_2, self.unsubscribed_user)}
        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_add_users', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id = folder.id)
        self.assertEqual(folder.users.all().count(), 2)
Ejemplo n.º 19
0
    def test_add_users_anon(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        post_data = {'users': self.subscribed_user_2}
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_add_users', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/add-users/'
            % folder.id,
            status_code=302,
            target_status_code=200)
Ejemplo n.º 20
0
    def test_delete_sub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        self.client.login(username = '******', password = '******')
        response = self.client.delete(
            reverse('rawdata.privatesharedfolder_delete', args = (folder.id,)),
            HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 200)

        self.client.logout()

        count = PrivateSharedFolder.objects.filter(id = folder.id).count()
        self.assertEqual(count, 0)
Ejemplo n.º 21
0
    def test_delete_anon(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        response = self.client.delete(
            reverse('rawdata.privatesharedfolder_delete', args=(folder.id, )))
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/delete/'
            % folder.id,
            status_code=302,
            target_status_code=200)

        count = PrivateSharedFolder.objects.filter(id=folder.id).count()
        self.assertEqual(count, 1)
Ejemplo n.º 22
0
    def test_add_image_unsub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        image = Image.objects.create(title = "test image", user = self.unsubscribed_user)

        post_data = {'image': image.id}
        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_add_image', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest',
            follow = True)
        self.assertEqual(response.status_code, 404)
        self.client.logout()
Ejemplo n.º 23
0
    def test_remove_user_anon(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.users.add(self.subscribed_user_2)

        response = self.client.post(
            reverse('rawdata.privatesharedfolder_remove_user',
                    kwargs = {'pk': folder.id, 'user_id': self.subscribed_user_2.id}),
            {},
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/remove-user/%d/' % (folder.id, self.subscribed_user_2.id),
            status_code = 302, target_status_code = 200)
Ejemplo n.º 24
0
    def test_add_data_wrong_sub(self):
        rawimage_id = upload_file(self)
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        post_data = {'images': rawimage_id}
        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_add_data', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 404)
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id=folder.id)
        self.assertEqual(folder.images.all().count(), 0)
Ejemplo n.º 25
0
    def test_add_image_unsub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        image = Image.objects.create(title="test image",
                                     user=self.unsubscribed_user)

        post_data = {'image': image.id}
        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_add_image', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest',
                                    follow=True)
        self.assertEqual(response.status_code, 404)
        self.client.logout()
Ejemplo n.º 26
0
    def test_add_image_sub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        image = Image.objects.create(title = "test image", user = self.subscribed_user)

        post_data = {'image': image.id}
        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_add_image', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id = folder.id)
        self.assertEqual(folder.processed_images.all().count(), 1)
Ejemplo n.º 27
0
    def test_add_users_unsub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        post_data = {'users': self.subscribed_user_2}
        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_add_users', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest',
            follow = True)
        self.assertRedirects(
            response,
            reverse('rawdata.restricted') + '?' + urlencode({'next': '/rawdata/privatesharedfolders/%d/add-users/' % folder.id}),
            status_code = 302, target_status_code = 200)
        self.client.logout()
Ejemplo n.º 28
0
    def test_download_anon(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        response = self.client.get(
            reverse('rawdata.privatesharedfolder_download',
                    args=(folder.id, )))
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/download/'
            % folder.id,
            status_code=302,
            target_status_code=200)
Ejemplo n.º 29
0
    def test_download_sub(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        self.client.login(username = '******', password = '******')
        response = self.client.get(reverse('rawdata.privatesharedfolder_download', args = (folder.id,)), follow = True)
        newid = max_id(TemporaryArchive)
        self.assertRedirects(
            response,
            reverse('rawdata.temporary_archive_detail', args = (newid,)),
            status_code = 302, target_status_code = 200)
        self.client.logout()
Ejemplo n.º 30
0
    def test_add_data_wrong_sub(self):
        rawimage_id = upload_file(self)
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        post_data = {'images': rawimage_id}
        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_add_data', args = (folder.id,)),
            post_data,
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.assertEqual(response.status_code, 404)
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id = folder.id)
        self.assertEqual(folder.images.all().count(), 0)
Ejemplo n.º 31
0
    def test_update_anon(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        post_data = {
            'name': "changed name",
            'description': "changed description"
        }
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_update', args=(folder.id, )),
            post_data)
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/update/'
            % folder.id,
            status_code=302,
            target_status_code=200)
Ejemplo n.º 32
0
    def test_delete_unsub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        self.client.login(username = '******', password = '******')
        response = self.client.delete(
            reverse('rawdata.privatesharedfolder_delete', args = (folder.id,)),
            follow = True)
        self.assertRedirects(
            response,
            reverse('rawdata.restricted') + '?' + urlencode({'next': '/rawdata/privatesharedfolders/%d/delete/' % folder.id}),
            status_code = 302, target_status_code = 200)

        self.client.logout()

        count = PrivateSharedFolder.objects.filter(id = folder.id).count()
        self.assertEqual(count, 1)
Ejemplo n.º 33
0
    def test_remove_user_wrong_sub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.users.add(self.unsubscribed_user)

        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_remove_user',
                    kwargs = {'pk': folder.id, 'user_id': self.unsubscribed_user.id}),
            {},
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.assertEqual(response.status_code, 404)
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id = folder.id)
        self.assertEqual(folder.users.all().count(), 1)
Ejemplo n.º 34
0
    def test_add_image_sub_invitee(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.users.add(self.subscribed_user_2)
        image = Image.objects.create(title="test image",
                                     user=self.subscribed_user_2)

        post_data = {'image': image.id}
        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_add_image', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id=folder.id)
        self.assertEqual(folder.processed_images.all().count(), 1)
Ejemplo n.º 35
0
    def test_remove_user_unsub(self):
        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.users.add(self.subscribed_user_2)

        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_remove_user',
                    kwargs = {'pk': folder.id, 'user_id': self.subscribed_user_2.id}),
            {},
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest',
            follow = True)
        self.assertRedirects(
            response,
            reverse('rawdata.restricted') + '?' + urlencode({'next': '/rawdata/privatesharedfolders/%d/remove-user/%d/' % (folder.id, self.subscribed_user_2.id)}),
            status_code = 302, target_status_code = 200)
        self.client.logout()
Ejemplo n.º 36
0
    def test_remove_user_anon(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.users.add(self.subscribed_user_2)

        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_remove_user',
            kwargs={
                'pk': folder.id,
                'user_id': self.subscribed_user_2.id
            }), {},
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertRedirects(
            response,
            'http://testserver/accounts/login/?next=/rawdata/privatesharedfolders/%d/remove-user/%d/'
            % (folder.id, self.subscribed_user_2.id),
            status_code=302,
            target_status_code=200)
Ejemplo n.º 37
0
    def test_download_sub(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        self.client.login(username='******', password='******')
        response = self.client.get(reverse(
            'rawdata.privatesharedfolder_download', args=(folder.id, )),
                                   follow=True)
        newid = max_id(TemporaryArchive)
        self.assertRedirects(response,
                             reverse('rawdata.temporary_archive_detail',
                                     args=(newid, )),
                             status_code=302,
                             target_status_code=200)
        self.client.logout()
Ejemplo n.º 38
0
    def test_remove_user_wrong_sub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.users.add(self.unsubscribed_user)

        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_remove_user',
            kwargs={
                'pk': folder.id,
                'user_id': self.unsubscribed_user.id
            }), {},
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.assertEqual(response.status_code, 404)
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id=folder.id)
        self.assertEqual(folder.users.all().count(), 1)
Ejemplo n.º 39
0
    def test_add_users_unsub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        post_data = {'users': self.subscribed_user_2}
        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_add_users', args=(folder.id, )),
                                    post_data,
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest',
                                    follow=True)
        self.assertRedirects(
            response,
            reverse('rawdata.restricted') + '?' + urlencode({
                'next':
                '/rawdata/privatesharedfolders/%d/add-users/' % folder.id
            }),
            status_code=302,
            target_status_code=200)
        self.client.logout()
Ejemplo n.º 40
0
    def test_delete_unsub(self):
        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        self.client.login(username='******', password='******')
        response = self.client.delete(reverse(
            'rawdata.privatesharedfolder_delete', args=(folder.id, )),
                                      follow=True)
        self.assertRedirects(
            response,
            reverse('rawdata.restricted') + '?' + urlencode({
                'next':
                '/rawdata/privatesharedfolders/%d/delete/' % folder.id
            }),
            status_code=302,
            target_status_code=200)

        self.client.logout()

        count = PrivateSharedFolder.objects.filter(id=folder.id).count()
        self.assertEqual(count, 1)
Ejemplo n.º 41
0
    def test_remove_data_sub(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(
            name = "test folder",
            description = "test description",
            creator = self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        self.assertEqual(folder.images.all().count(), 1)

        self.client.login(username = '******', password = '******')
        response = self.client.post(
            reverse('rawdata.privatesharedfolder_remove_data',
                    kwargs = {'pk': folder.id, 'rawimage_pk': rawimage_id}),
            {},
            HTTP_X_REQUESTED_WITH = 'XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id = folder.id)
        self.assertEqual(folder.images.all().count(), 0)
Ejemplo n.º 42
0
    def test_remove_data_sub(self):
        rawimage_id = upload_file(self)

        folder = PrivateSharedFolder(name="test folder",
                                     description="test description",
                                     creator=self.subscribed_user)
        folder.save()

        folder.images.add(rawimage_id)

        self.assertEqual(folder.images.all().count(), 1)

        self.client.login(username='******', password='******')
        response = self.client.post(reverse(
            'rawdata.privatesharedfolder_remove_data',
            kwargs={
                'pk': folder.id,
                'rawimage_pk': rawimage_id
            }), {},
                                    HTTP_X_REQUESTED_WITH='XMLHttpRequest')
        self.client.logout()

        folder = PrivateSharedFolder.objects.get(id=folder.id)
        self.assertEqual(folder.images.all().count(), 0)