@@ -0,0 +1,1357 @@
+import mock%0Aimport pytest%0A%0Afrom django import forms%0A%0Afrom wheelcms_axle.forms import ParentField, BaseForm%0Afrom .models import Type1%0A%0Aclass TestParentField(object):%0A    def test_init(self):%0A        something = mock.Mock()%0A        f = ParentField(something)%0A        assert f.parent is None%0A        assert f.parenttype == something%0A%0A    def test_clean_noparent(self):%0A        something = mock.Mock()%0A        f = ParentField(something)%0A        with pytest.raises(forms.ValidationError):%0A            f.clean(%22%22)%0A%0A    def test_clean_mistype(self):%0A        f = ParentField(str)%0A        f.parent = mock.MagicMock()%0A        with pytest.raises(forms.ValidationError):%0A            f.clean(%22%22)%0A%0A    def test_clean(self):%0A        class DummyContent(object):%0A            def content(self):%0A                return %22content%22%0A%0A        f = ParentField(str)%0A        f.parent = DummyContent()%0A%0A        assert f.clean(%22%22) == %22content%22%0A%0A    def test_forminit(self, client):%0A        %22%22%22 A ParentField should receive its parent form the form %22%22%22%0A        ## unfortunately, BaseForm depends on lots of stuff, including%0A        ## database access%0A        class Form(BaseForm):%0A            class Meta:%0A                model = Type1%0A%0A            field = ParentField()%0A%0A        parent = mock.MagicMock()%0A        form = Form(parent)%0A%0A        assert form.fields%5B'field'%5D.parent == parent%0A

Test ParentField / form