Ejemplo n.º 1
0
    def test_queryset(self):
        GastroFactory()
        GastroFactory(closed=None)

        gastro_list = GastrosClosedView().get_queryset()
        for gastro in gastro_list:
            self.assertNotEqual(gastro.closed, None)
Ejemplo n.º 2
0
 def test_login_required(self):
     gastro = GastroFactory()
     response = Client().get(
         reverse(self.view_name, args=[gastro.id_string]))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(
         response.url,
         f"""{reverse(self.login_view_name)}?next=/location/gastro/{gastro.id_string}/edit/""",
     )
Ejemplo n.º 3
0
 def test_login_required(self):
     gastro = GastroFactory()
     response = Client().get(
         reverse(self.view_name, args=[gastro.id_string]))
     self.assertEqual(response.status_code, 302)
     self.assertEqual(
         response.url,
         f"""{reverse("data:login")}?next={reverse(self.view_name, args=[gastro.id_string])}""",
     )
Ejemplo n.º 4
0
 def test_update(self):
     gastro_submit = GastroFactory()
     data = create_gastro_form_data(factory=GastroFactory, form=GastroForm)
     response = self.client.post(reverse(self.view_name,
                                         args=[gastro_submit.id_string]),
                                 data=data)
     self.assertEqual(response.status_code, 302)
     gastro_submit_edited = Gastro.objects.get(
         id_string=gastro_submit.id_string)
     self.assertNotEqual(gastro_submit.name, gastro_submit_edited.name)
     self.assertEqual(gastro_submit_edited.last_editor, self.user)
Ejemplo n.º 5
0
 def test_delete(self):
     user = get_user_model().objects.create_user(username="******")
     client = Client()
     client.force_login(user=user)
     gastro = GastroFactory()
     self.assertIsNotNone(Gastro.objects.get(id_string=gastro.id_string))
     response = client.post(reverse(self.view_name,
                                    args=[gastro.id_string]))
     self.assertEqual(response.url, f"""{reverse("data:dashboard")}""")
     self.assertEqual(
         len(Gastro.objects.filter(id_string=gastro.id_string)), 0)
Ejemplo n.º 6
0
 def test_sanity(self):
     GastroFactory()
     response = self.client.get(reverse(self.view_name))
     self.assertEqual(response.status_code, 200)
Ejemplo n.º 7
0
 def test_sanity(self):
     gastro = GastroFactory()
     response = self.client.get(
         reverse("data:gastro-update", args=[gastro.id_string]))
     self.assertEqual(response.status_code, 200)