コード例 #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)
コード例 #2
0
ファイル: test_forms.py プロジェクト: divio/django-appdata
 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)
コード例 #3
0
ファイル: test_fields.py プロジェクト: divio/django-appdata
    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()
コード例 #4
0
ファイル: test_fields.py プロジェクト: divio/django-appdata
    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))
コード例 #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()
コード例 #6
0
ファイル: test_fields.py プロジェクト: divio/django-appdata
    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'))
コード例 #7
0
ファイル: test_fields.py プロジェクト: divio/django-appdata
    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'))
コード例 #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))
コード例 #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'))
コード例 #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'))
コード例 #11
0
ファイル: test_fields.py プロジェクト: divio/django-appdata
    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)
コード例 #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)
コード例 #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))
コード例 #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))