Example #1
0
 def setUp(self):
     super(TestAppDataForms, self).setUp()
     MyAppContainer = AppDataContainer.from_form(self.MyForm)
     app_registry.register('myapp', MyAppContainer)
     self.data = {'title': 'First!', 'publish_from': '2010-10-1'}
     MyOtherContainer = AppDataContainer.from_form(self.MyOtherForm)
     app_registry.register('myotherapp', MyOtherContainer)
Example #2
0
 def setUp(self):
     super(TestAppDataForms, self).setUp()
     MyAppContainer = AppDataContainer.from_form(self.MyForm)
     app_registry.register('myapp', MyAppContainer)
     self.data = {
         'title': 'First!',
         'publish_from': '2010-10-1'
     }
     MyOtherContainer = AppDataContainer.from_form(self.MyOtherForm)
     app_registry.register('myotherapp', MyOtherContainer)
Example #3
0
    def setUp(self):
        super(TestSerialization, self).setUp()

        MyAppContainer = AppDataContainer.from_form(self.MyForm)
        app_registry.register('myapp', MyAppContainer)
        self.article = Article()
        self.article.app_data.myapp.publish_from = date(2012, 8, 26)
        self.article.save()
Example #4
0
    def test_container_from_form(self):
        class MyForm(AppDataForm):
            publish_from = forms.DateField()
        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_true(isinstance(art.app_data['myapp'], MyAppContainer))
Example #5
0
    def setUp(self):
        super(TestSerialization, self).setUp()

        MyAppContainer = AppDataContainer.from_form(self.MyForm)
        app_registry.register('myapp', MyAppContainer)
        self.article = Article()
        self.article.app_data.myapp.publish_from = date(2012, 8, 26)
        self.article.save()
Example #6
0
    def test_get_fallback_value(self):
        class MyForm(AppDataForm):
            title = forms.CharField(max_length=25, initial='Hullo!')
        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_equals(None, art.app_data.myapp.get('foo'))
        tools.assert_equals('bar', art.app_data.myapp.get('foo', 'bar'))
Example #7
0
    def test_initial_get_used_as_default(self):
        class MyForm(AppDataForm):
            title = forms.CharField(max_length=25, initial='Hullo!')
        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_true(isinstance(art.app_data['myapp'], MyAppContainer))
        tools.assert_equals('Hullo!', art.app_data.myapp.get('title'))
Example #8
0
    def test_container_from_form(self):
        class MyForm(AppDataForm):
            publish_from = forms.DateField()

        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_true(isinstance(art.app_data['myapp'], MyAppContainer))
Example #9
0
    def test_get_fallback_value(self):
        class MyForm(AppDataForm):
            title = forms.CharField(max_length=25, initial='Hullo!')

        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_equals(None, art.app_data.myapp.get('foo'))
        tools.assert_equals('bar', art.app_data.myapp.get('foo', 'bar'))
Example #10
0
    def test_initial_get_used_as_default(self):
        class MyForm(AppDataForm):
            title = forms.CharField(max_length=25, initial='Hullo!')

        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_true(isinstance(art.app_data['myapp'], MyAppContainer))
        tools.assert_equals('Hullo!', art.app_data.myapp.get('title'))
Example #11
0
    def test_get_semantics_for_getitem(self):
        class MyForm(AppDataForm):
            title = forms.CharField(max_length=25, initial='Hullo!')
            description = forms.CharField(max_length=25, required=False)
        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_equals('Hullo!', art.app_data.myapp.title)
        # empty initial value falls back to field's type
        tools.assert_equals('', art.app_data.myapp.description)
Example #12
0
    def test_get_semantics_for_getitem(self):
        class MyForm(AppDataForm):
            title = forms.CharField(max_length=25, initial='Hullo!')
            description = forms.CharField(max_length=25, required=False)

        MyAppContainer = AppDataContainer.from_form(MyForm)
        app_registry.register('myapp', MyAppContainer)

        art = Article()
        tools.assert_equals('Hullo!', art.app_data.myapp.title)
        # empty initial value falls back to field's type
        tools.assert_equals('', art.app_data.myapp.description)
Example #13
0
 def setUp(self):
     super(TestMultiForm, self).setUp()
     MyAppContainer = AppDataContainer.from_form(self.MyForm)
     app_registry.register('myapp', MyAppContainer)
     app_registry.register('myapp2', AppDataContainer.from_form(self.MyForm2))
Example #14
0
 def setUp(self):
     super(TestMultiForm, self).setUp()
     MyAppContainer = AppDataContainer.from_form(self.MyForm)
     app_registry.register('myapp', MyAppContainer)
     app_registry.register('myapp2',
                           AppDataContainer.from_form(self.MyForm2))