def test_get_allowed(self):
     """
     SuccessView should be successfull if referrer is recognized
     """
     self.request.META["HTTP_REFERER"] = reverse("tracking:charter_add")
     response = SuccessView.as_view()(self.request, obj_type="charter", pk=9999)
     self.assertEqual(response.status_code, 200)
 def setUp(self):
     user, _ = User.objects.get_or_create(
         username="******",
         email="*****@*****.**",
         password="******",
     )
     language = Language.objects.create(
         id=9999,
         code="ts",
         name="Test Language",
     )
     department = Department.objects.create(name="Test Department", )
     self.charter = Charter.objects.create(
         id=9999,
         language=language,
         start_date=timezone.now().date(),
         end_date=timezone.now().date(),
         lead_dept=department,
     )
     self.event = Event.objects.create(
         id=9999,
         charter=self.charter,
         start_date=timezone.now().date(),
         end_date=timezone.now().date(),
         lead_dept=department,
     )
     self.request = RequestFactory().get('/tracking/success/')
     self.request.user = user
     self.view = setup_view(SuccessView(),
                            self.request,
                            obj_type="charter",
                            pk=9999)
 def test_get_no_allowed(self):
     """
     SuccessView should redirect to home page if referrer is not recognized
     """
     self.request.META["HTTP_REFERER"] = "wrong/url"
     response = SuccessView.as_view()(self.request, obj_type="charter", pk=9999)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response.url, reverse("tracking:project_list"))
 def test_get_allowed(self):
     """
     SuccessView should be successfull if referrer is recognized
     """
     self.request.META["HTTP_REFERER"] = reverse("tracking:charter_add")
     response = SuccessView.as_view()(self.request,
                                      obj_type="charter",
                                      pk=9999)
     self.assertEqual(response.status_code, 200)
 def test_get_no_allowed(self):
     """
     SuccessView should redirect to home page if referrer is not recognized
     """
     self.request.META["HTTP_REFERER"] = "wrong/url"
     response = SuccessView.as_view()(self.request,
                                      obj_type="charter",
                                      pk=9999)
     self.assertEqual(response.status_code, 302)
     self.assertEqual(response.url, reverse("tracking:project_list"))