Ejemplo n.º 1
0
    def test_load_FormB_GET_POST(self):
        form_class = FormB.__module__ + '.' + FormB.__name__
        prefix = 'f3-fA2'

        request = request_factory.get('/', data={'f3-fA2-fB1': 'aaa'})
        params = signing.dumps((form_class, None, prefix, None), compress=True)
        response = views.load(request, params)
        html = response.content

        self.assertEqual(html.count('This field is required'), 0, html)

        request = request_factory.post('/', data={'f3-fA2-fB1': 'aaa'})
        params = signing.dumps((form_class, None, prefix, None), compress=True)
        response = views.load(request, params)
        html = response.content

        self.assertEqual(html.count('This field is required'), 1, html)
Ejemplo n.º 2
0
    def test_load_FormE_GET(self):
        form_class = FormE.__module__ + '.' + FormE.__name__
        prefix = 'f5-10'
        request = request_factory.get('/', data={'f5-10-fE1': 'aaa', 'f5-10-fE2': 'bbb'})
        params = signing.dumps((form_class, None, prefix, None), compress=True)
        response = views.load(request, params)
        html = response.content

        self.assertEqual(html.count('name="f5-10-fE1"'), 1, html)
        self.assertEqual(html.count('name="f5-10-fE2"'), 1, html)
Ejemplo n.º 3
0
    def test_load_FormD_empty(self):
        form_class = FormD.__module__ + '.' + FormD.__name__
        prefix = 'f4'

        request = request_factory.get('/', data={})
        params = signing.dumps((form_class, None, prefix, None), compress=True)
        response = views.load(request, params)
        html = response.content
        self.assertEqual(html.count('name="f4-fD1"'), 1, html)
        self.assertEqual(html.count('name="f4-fD2"'), 1, html)
        self.assertEqual(html.count('name="f4-fD3"'), 1, html)
Ejemplo n.º 4
0
    def test_load_FormE_GET_formset(self):
        form_class = MainTestingForm.__module__ + '.' + MainTestingForm.__name__
        prefix = ''
        field = 'f5'
        request = request_factory.get('/', data={'f5-0-fE1': 'aaa', 'f5-0-fE2': 'bbb'})
        params = signing.dumps((form_class, field, prefix, None), compress=True)
        response = views.load(request, params)
        html = response.content

        self.assertEqual(html.count('name="f5-0-fE1"'), 1, html)
        self.assertEqual(html.count('value="aaa"'), 1, html)
        self.assertEqual(html.count('name="f5-0-fE2"'), 1, html)
        self.assertEqual(html.count('value="bbb"'), 1, html)