Пример #1
0
    def test_error(self):
        request = RequestFactory().post("/dslform/form/")
        response = dslform(request, "form", "dslforms/", save_method)
        self.assertEqual(response.status_code, 200)

        form = response.context_data["form"]
        self.assertEqual(form.errors["name"][0], "Please enter your name")
Пример #2
0
    def test_get(self):
        request = RequestFactory().get("/dslform/form/")
        response = dslform(request, "form", "dslforms/", save_method)
        self.assertEqual(response.status_code, 200)

        form = response.context_data["form"]
        self.assertEqual(form.fields["name"].max_length, 100)
Пример #3
0
    def test_error(self):
        request = RequestFactory().post("/dslform/form/")
        response = dslform(request, "form", "dslforms/", save_method)
        self.assertEqual(response.status_code, 200)

        form = response.context_data["form"]
        self.assertEqual(form.errors["name"][0], "Please enter your name")
Пример #4
0
    def test_get(self):
        request = RequestFactory().get("/dslform/form/")
        response = dslform(request, "form", "dslforms/", save_method)
        self.assertEqual(response.status_code, 200)

        form = response.context_data["form"]
        self.assertEqual(form.fields["name"].max_length, 100)
Пример #5
0
 def test_missing_display_block(self):
     request = RequestFactory().get("/dslform/missing-display/")
     with self.assertRaises(Exception):
         dslform(request, "missing-display", "dslforms/", save_method)
Пример #6
0
 def test_404(self):
     request = RequestFactory().get("/dslform/form404/")
     with self.assertRaises(Http404):
         dslform(request, "form404", "dslforms/", save_method)
Пример #7
0
 def test_post(self):
     request = RequestFactory().post("/dslform/form/", dict(name="Name"))
     response = dslform(request, "form", "dslforms/", save_method)
     self.assertEqual(response.status_code, 302)
     self.assertTrue("form" in response.context_data)
     self.assertEqual(response.context_data["result"], "Saved")
Пример #8
0
 def test_missing_display_block(self):
     request = RequestFactory().get("/dslform/missing-display/")
     with self.assertRaises(Exception):
         dslform(request, "missing-display", "dslforms/", save_method)
Пример #9
0
 def test_404(self):
     request = RequestFactory().get("/dslform/form404/")
     with self.assertRaises(Http404):
         dslform(request, "form404", "dslforms/", save_method)
Пример #10
0
 def test_post(self):
     request = RequestFactory().post("/dslform/form/", dict(name="Name"))
     response = dslform(request, "form", "dslforms/", save_method)
     self.assertEqual(response.status_code, 302)
     self.assertTrue("form" in response.context_data)
     self.assertEqual(response.context_data["result"], "Saved")