Пример #1
0
    def test_real_value(self):
        """setting returns real value correctyly"""
        setting_model = Setting(
            python_type='list',
            dry_value='',
        )
        self.assertEqual(setting_model.value, [])

        setting_model = Setting(
            python_type='list',
            dry_value='Arthur,Lancelot,Patsy',
        )
        self.assertEqual(setting_model.value, ['Arthur', 'Lancelot', 'Patsy'])

        setting_model = Setting(
            python_type='list',
            default_value='Arthur,Patsy',
        )
        self.assertEqual(setting_model.value, ['Arthur', 'Patsy'])

        setting_model = Setting(
            python_type='list',
            dry_value='Arthur,Robin,Patsy',
            default_value='Arthur,Patsy',
        )
        self.assertEqual(setting_model.value, ['Arthur', 'Robin', 'Patsy'])
Пример #2
0
    def test_hydrate_dehydrate_list(self):
        """list is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type='list')

        wet_value = ['Lorem', 'Ipsum', 'Dolor', 'Met']
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #3
0
    def test_hydrate_dehydrate_int(self):
        """int value is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type='int')

        wet_value = 9001
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #4
0
    def test_hydrate_dehydrate_string(self):
        """string value is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type='string')

        wet_value = 'Lorem Ipsum'
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #5
0
    def test_hydrate_dehydrate_empty_list(self):
        """empty list is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type='list')

        wet_value = []
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #6
0
    def test_hydrate_dehydrate_list(self):
        """list is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type="list")

        wet_value = ["Lorem", "Ipsum", "Dolor", "Met"]
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #7
0
    def test_hydrate_dehydrate_int(self):
        """int value is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type="int")

        wet_value = 9001
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #8
0
    def test_hydrate_dehydrate_string(self):
        """string value is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type="string")

        wet_value = "Lorem Ipsum"
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #9
0
    def test_hydrate_dehydrate_empty_list(self):
        """empty list is correctly hydrated and dehydrated in model"""
        setting = Setting(python_type="list")

        wet_value = []
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #10
0
    def test_field_extra(self):
        """field extra is set correctly"""
        setting_model = Setting()

        test_extra = {}
        setting_model.field_extra = test_extra
        self.assertEqual(setting_model.field_extra, test_extra)

        test_extra = {'min_lenght': 5, 'max_length': 12}
        setting_model.field_extra = test_extra
        self.assertEqual(setting_model.field_extra, test_extra)
Пример #11
0
    def test_field_extra(self):
        """field extra is set correctly"""
        setting_model = Setting()

        test_extra = {}
        setting_model.field_extra = test_extra
        self.assertEqual(setting_model.field_extra, test_extra)

        test_extra = {'min_lenght': 5, 'max_length': 12}
        setting_model.field_extra = test_extra
        self.assertEqual(setting_model.field_extra, test_extra)
Пример #12
0
    def test_set_value(self):
        """setting sets value correctyly"""
        setting_model = Setting(python_type='int',
                                dry_value='42',
                                default_value='9001')

        setting_model.value = 3000
        self.assertEqual(setting_model.value, 3000)
        self.assertEqual(setting_model.dry_value, '3000')
        setting_model.value = None
        self.assertEqual(setting_model.value, 9001)
        self.assertEqual(setting_model.dry_value, None)
Пример #13
0
    def test_set_value(self):
        """setting sets value correctyly"""
        setting_model = Setting(python_type='int',
                                dry_value='42',
                                default_value='9001')

        setting_model.value = 3000
        self.assertEqual(setting_model.value, 3000)
        self.assertEqual(setting_model.dry_value, '3000')
        setting_model.value = None
        self.assertEqual(setting_model.value, 9001)
        self.assertEqual(setting_model.dry_value, None)
Пример #14
0
    def test_hydrate_dehydrate_bool(self):
        """bool values are correctly hydrated and dehydrated in model"""
        setting = Setting(python_type='bool')

        wet_value = True
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)

        wet_value = False
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)
Пример #15
0
    def test_hydrate_dehydrate_bool(self):
        """bool values are correctly hydrated and dehydrated in model"""
        setting = Setting(python_type="bool")

        wet_value = True
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)

        wet_value = False
        dry_value = dehydrate_value(setting.python_type, wet_value)

        setting.value = wet_value
        self.assertEqual(setting.value, wet_value)
        self.assertEqual(setting.dry_value, dry_value)