Exemplo n.º 1
0
    def setUp(self):
        super(UserImagesTest, self).setUp()
        self.file = self.create_test_image()

        image = self.create_test_image()
        url = reverse('images')
        request = self.factory.post(url, {'image': image})

        # simulate a logged-in user
        request.user = self.user
        ImagesView.as_view()(request)
    def setUp(self):
        super(UserImagesTest, self).setUp()
        self.file = self.create_test_image()

        image = self.create_test_image()
        url = reverse('images')
        request = self.factory.post(url, {
            'image': image
        })

        # simulate a logged-in user
        request.user = self.user
        ImagesView.as_view()(request)
    def test_user_can_get_all_uploaded_images(self):
        url = reverse('images')
        request = self.factory.get(url)

        # simulate a logged-in user
        request.user = self.user
        response = ImagesView.as_view()(request)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'title')
Exemplo n.º 4
0
    def test_user_can_get_all_uploaded_images(self):
        url = reverse('images')
        request = self.factory.get(url)

        # simulate a logged-in user
        request.user = self.user
        response = ImagesView.as_view()(request)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'title')
Exemplo n.º 5
0
    def test_can_upload_image(self):
        image = self.create_test_image()
        url = reverse('images')
        request = self.factory.post(url, {'image': image})

        # simulate a logged-in user
        request.user = self.user
        response = ImagesView.as_view()(request)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'test.png')
    def test_can_upload_image(self):
        image = self.create_test_image()
        url = reverse('images')
        request = self.factory.post(url, {
            'image': image
        })

        # simulate a logged-in user
        request.user = self.user
        response = ImagesView.as_view()(request)

        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'test.png')
    def test_user_can_delete_image(self):
        url = reverse('images')
        json_data = json.dumps({
            'title': 'image',
            'current_filter': 'blur',
            'filtered': False,
            'id': 1,
        })
        request = self.factory.delete(
            url, json_data, content_type='application/json',
            HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        # simulate a logged-in user
        request.user = self.user
        response = ImagesView.as_view()(request)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'success')
Exemplo n.º 8
0
    def test_user_can_delete_image(self):
        url = reverse('images')
        json_data = json.dumps({
            'title': 'image',
            'currentFilter': 'blur',
            'filtered': False,
            'id': 1,
        })
        request = self.factory.delete(url,
                                      json_data,
                                      content_type='application/json',
                                      HTTP_X_REQUESTED_WITH='XMLHttpRequest')

        # simulate a logged-in user
        request.user = self.user
        response = ImagesView.as_view()(request)
        self.assertEqual(response.status_code, 200)
        self.assertContains(response, 'success')