Example #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")
Example #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)
Example #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")
Example #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)
Example #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)
Example #6
0
 def test_404(self):
     request = RequestFactory().get("/dslform/form404/")
     with self.assertRaises(Http404):
         dslform(request, "form404", "dslforms/", save_method)
Example #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")
Example #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)
Example #9
0
 def test_404(self):
     request = RequestFactory().get("/dslform/form404/")
     with self.assertRaises(Http404):
         dslform(request, "form404", "dslforms/", save_method)
Example #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")