Exemple #1
0
    def test_keys_include_formset_prefix(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field_name in empty_data:
            self.assertTrue(formset.prefix in field_name)
Exemple #2
0
    def test_returns_empty_form_fields_without_prefix_stub(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field_name in empty_data:
            self.assertFalse('__prefix__' in field_name)
Exemple #3
0
    def test_keys_include_formset_prefix(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field_name in empty_data:
            self.assertTrue(formset.prefix in field_name)
Exemple #4
0
    def test_returns_all_fields(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field in formset.empty_form.fields:
            self.assertTrue([k for k in empty_data if k.endswith(field)])
Exemple #5
0
    def test_returns_empty_form_fields_without_prefix_stub(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field_name in empty_data:
            self.assertFalse('__prefix__' in field_name)
Exemple #6
0
    def test_index_can_be_specified(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset, index=42)

        for field_name in empty_data:
            self.assertTrue("42" in field_name.split("-"), "Field name (%s) does not use specified index." % field_name)
Exemple #7
0
    def test_returns_all_fields(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field in formset.empty_form.fields:
            self.assertTrue([k for k in empty_data if k.endswith(field)])
Exemple #8
0
    def test_hidden_initial_fields_included(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        # we know that the first_name field in our test form wants to
        # include the initial value in a hidden field
        self.assertEqual(empty_data["initial-form-1-first_name"], "Larry")
Exemple #9
0
    def test_index_can_be_specified(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset, index=42)

        for field_name in empty_data:
            self.assertTrue(
                '42' in field_name.split('-'),
                "Field name (%s) does not use specified index." % field_name)
Exemple #10
0
    def test_contains_next_form_index(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field_name in empty_data:
            self.assertTrue(
                str(len(formset.initial_forms) + 1) in field_name.split('-'),
                "Field name (%s) does not include next empty form index." %
                field_name)
Exemple #11
0
    def test_contains_next_form_index(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        for field_name in empty_data:
            self.assertTrue(
                str(len(formset.initial_forms) + 1) in field_name.split("-"),
                "Field name (%s) does not include next empty form index." % field_name,
            )
Exemple #12
0
    def test_hidden_initial_fields_included(self):

        formset = ContactFormSet()
        empty_data = empty_form_data(formset)

        # we know that the first_name field in our test form wants to
        # include the initial value in a hidden field
        self.assertEqual(
            empty_data['initial-form-1-first_name'],
            'Larry',
        )
Exemple #13
0
    def test_returns_dict(self):

        formset = ContactFormSet()

        self.assertIsInstance(empty_form_data(formset), dict)
Exemple #14
0
    def test_returns_dict(self):

        formset = ContactFormSet()

        self.assertIsInstance(empty_form_data(formset), dict)