Exemple #1
0
    def test_get_draft_object_with_admin(self):
        self.observation.status = 'draft'
        self.observation.save()

        view = SingleAllContributionAPIView()
        view.get_object(self.admin, self.observation.project.id,
                        self.observation.id)
Exemple #2
0
    def test_get_draft_object_with_admin(self):
        self.observation.status = 'draft'
        self.observation.save()

        view = SingleAllContributionAPIView()
        view.get_object(
            self.admin, self.observation.project.id, self.observation.id)
Exemple #3
0
 def _delete(self, user):
     url = reverse('api:project_single_observation',
                   kwargs={
                       'project_id': self.project.id,
                       'observation_id': self.observation.id
                   })
     request = self.factory.delete(url, content_type='application/json')
     force_authenticate(request, user=user)
     view = SingleAllContributionAPIView.as_view()
     return view(request,
                 project_id=self.project.id,
                 observation_id=self.observation.id).render()
Exemple #4
0
 def _delete(self, user):
     url = reverse(
         'api:project_single_observation',
         kwargs={
             'project_id': self.project.id,
             'observation_id': self.observation.id
         }
     )
     request = self.factory.delete(url, content_type='application/json')
     force_authenticate(request, user=user)
     view = SingleAllContributionAPIView.as_view()
     return view(
         request, project_id=self.project.id,
         observation_id=self.observation.id).render()
Exemple #5
0
 def test_api_with_admin(self):
     CommentFactory.create_batch(5, **{'commentto': self.observation})
     factory = APIRequestFactory()
     url = reverse('api:project_single_observation',
                   kwargs={
                       'project_id': self.project.id,
                       'observation_id': self.observation.id
                   })
     request = factory.get(url)
     force_authenticate(request, user=self.admin)
     theview = SingleAllContributionAPIView.as_view()
     response = theview(request,
                        project_id=self.project.id,
                        observation_id=self.observation.id).render()
     self.assertEqual(response.status_code, 200)
Exemple #6
0
 def test_api_with_admin(self):
     CommentFactory.create_batch(5, **{'commentto': self.observation})
     factory = APIRequestFactory()
     url = reverse('api:project_single_observation', kwargs={
         'project_id': self.project.id,
         'observation_id': self.observation.id
     })
     request = factory.get(url)
     force_authenticate(request, user=self.admin)
     theview = SingleAllContributionAPIView.as_view()
     response = theview(
         request,
         project_id=self.project.id,
         observation_id=self.observation.id).render()
     self.assertEqual(response.status_code, 200)
Exemple #7
0
 def test_get_object_with_some_dude(self):
     some_dude = UserF.create()
     view = SingleAllContributionAPIView()
     view.get_object(some_dude, self.observation.project.id,
                     self.observation.id)
Exemple #8
0
 def test_get_object_with_admin(self):
     view = SingleAllContributionAPIView()
     observation = view.get_object(self.admin, self.observation.project.id,
                                   self.observation.id)
     self.assertEqual(observation, self.observation)
Exemple #9
0
 def test_get_object_with_creator(self):
     view = SingleAllContributionAPIView()
     view.get_object(self.creator, self.observation.project.id,
                     self.observation.id)
Exemple #10
0
 def test_get_object_with_some_dude(self):
     some_dude = UserF.create()
     view = SingleAllContributionAPIView()
     view.get_object(
         some_dude, self.observation.project.id, self.observation.id)
Exemple #11
0
 def test_get_object_with_admin(self):
     view = SingleAllContributionAPIView()
     observation = view.get_object(
         self.admin, self.observation.project.id, self.observation.id)
     self.assertEqual(observation, self.observation)
Exemple #12
0
 def test_get_object_with_creator(self):
     view = SingleAllContributionAPIView()
     view.get_object(
         self.creator, self.observation.project.id, self.observation.id)