Ejemplo n.º 1
0
    def test_delete_and_respond_with_some_dude(self):
        url = reverse('api:project_single_media',
                      kwargs={
                          'project_id': self.project.id,
                          'contribution_id': self.contribution.id,
                          'file_id': self.image_file.id
                      })

        request = self.factory.delete(url)
        view = MediaFileSingleAbstractView()
        view.request = request

        view.delete_and_respond(UserF.create(), self.image_file)
Ejemplo n.º 2
0
    def test_delete_and_respond_with_admin(self):
        url = reverse('api:project_single_media',
                      kwargs={
                          'project_id': self.project.id,
                          'contribution_id': self.contribution.id,
                          'file_id': self.image_file.id
                      })

        request = self.factory.delete(url)
        view = MediaFileSingleAbstractView()
        view.request = request

        view.delete_and_respond(self.admin, self.image_file)
        MediaFile.objects.get(pk=self.image_file.id)
Ejemplo n.º 3
0
    def test_delete_and_respond_with_some_dude(self):
        url = reverse(
            'api:project_single_media',
            kwargs={
                'project_id': self.project.id,
                'contribution_id': self.contribution.id,
                'file_id': self.image_file.id
            }
        )

        request = self.factory.delete(url)
        view = MediaFileSingleAbstractView()
        view.request = request

        view.delete_and_respond(UserFactory.create(), self.image_file)
Ejemplo n.º 4
0
    def test_delete_and_respond_with_admin(self):
        url = reverse(
            'api:project_single_media',
            kwargs={
                'project_id': self.project.id,
                'contribution_id': self.contribution.id,
                'file_id': self.image_file.id
            }
        )

        request = self.factory.delete(url)
        view = MediaFileSingleAbstractView()
        view.request = request

        view.delete_and_respond(self.admin, self.image_file)
        MediaFile.objects.get(pk=self.image_file.id)
Ejemplo n.º 5
0
    def test_get_and_respond(self):
        url = reverse('api:project_single_media',
                      kwargs={
                          'project_id': self.project.id,
                          'contribution_id': self.contribution.id,
                          'file_id': self.image_file.id
                      })

        request = self.factory.get(url)
        view = MediaFileSingleAbstractView()
        view.request = request

        response = self.render(
            view.get_and_respond(self.admin, self.image_file))
        response_json = json.loads(response.content)
        self.assertEqual(response_json.get('id'), self.image_file.id)
Ejemplo n.º 6
0
    def test_get_and_respond(self):
        url = reverse(
            'api:project_single_media',
            kwargs={
                'project_id': self.project.id,
                'contribution_id': self.contribution.id,
                'file_id': self.image_file.id
            }
        )

        request = self.factory.get(url)
        view = MediaFileSingleAbstractView()
        view.request = request

        response = self.render(
            view.get_and_respond(
                self.admin,
                self.image_file
            )
        )
        response_json = json.loads(response.content)
        self.assertEqual(response_json.get('id'), self.image_file.id)