Пример #1
0
 def value(self):
     if not self.dry_value and self.default_value:
         return hydrators.hydrate_value(self.python_type,
                                        self.default_value)
     else:
         return hydrators.hydrate_value(self.python_type,
                                        self.dry_value)
Пример #2
0
    def test_value_error(self):
        """unsupported type raises ValueError"""
        with self.assertRaises(ValueError):
            hydrate_value('eric', None)

        with self.assertRaises(ValueError):
            dehydrate_value('eric', None)
Пример #3
0
    def test_value_error(self):
        """unsupported type raises ValueError"""
        with self.assertRaises(ValueError):
            hydrate_value("eric", None)

        with self.assertRaises(ValueError):
            dehydrate_value("eric", None)
Пример #4
0
    def test_hydrate_dehydrate_bool(self):
        """bool values are correctly hydrated and dehydrated"""
        wet_value = True
        dry_value = dehydrate_value('bool', wet_value)
        self.assertEqual(hydrate_value('bool', dry_value), wet_value)

        wet_value = False
        dry_value = dehydrate_value('bool', wet_value)
        self.assertEqual(hydrate_value('bool', dry_value), wet_value)
Пример #5
0
    def test_hydrate_dehydrate_bool(self):
        """bool values are correctly hydrated and dehydrated"""
        wet_value = True
        dry_value = dehydrate_value("bool", wet_value)
        self.assertEqual(hydrate_value("bool", dry_value), wet_value)

        wet_value = False
        dry_value = dehydrate_value("bool", wet_value)
        self.assertEqual(hydrate_value("bool", dry_value), wet_value)
Пример #6
0
 def test_hydrate_dehydrate_string(self):
     """string value is correctly hydrated and dehydrated"""
     wet_value = 'Ni!'
     dry_value = dehydrate_value('string', wet_value)
     self.assertEqual(hydrate_value('string', dry_value), wet_value)
Пример #7
0
 def test_hydrate_dehydrate_empty_list(self):
     """empty list is correctly hydrated and dehydrated"""
     wet_value = []
     dry_value = dehydrate_value('list', wet_value)
     self.assertEqual(hydrate_value('list', dry_value), wet_value)
Пример #8
0
 def test_hydrate_dehydrate_list(self):
     """list is correctly hydrated and dehydrated"""
     wet_value = ['foxtrot', 'uniform', 'hotel']
     dry_value = dehydrate_value('list', wet_value)
     self.assertEqual(hydrate_value('list', dry_value), wet_value)
Пример #9
0
 def test_hydrate_dehydrate_int(self):
     """int value is correctly hydrated and dehydrated"""
     wet_value = 9001
     dry_value = dehydrate_value('int', wet_value)
     self.assertEqual(hydrate_value('int', dry_value), wet_value)
Пример #10
0
 def test_hydrate_dehydrate_string(self):
     """string value is correctly hydrated and dehydrated"""
     wet_value = "Ni!"
     dry_value = dehydrate_value("string", wet_value)
     self.assertEqual(hydrate_value("string", dry_value), wet_value)
Пример #11
0
 def test_hydrate_dehydrate_empty_list(self):
     """empty list is correctly hydrated and dehydrated"""
     wet_value = []
     dry_value = dehydrate_value("list", wet_value)
     self.assertEqual(hydrate_value("list", dry_value), wet_value)
Пример #12
0
 def test_hydrate_dehydrate_list(self):
     """list is correctly hydrated and dehydrated"""
     wet_value = ["foxtrot", "uniform", "hotel"]
     dry_value = dehydrate_value("list", wet_value)
     self.assertEqual(hydrate_value("list", dry_value), wet_value)
Пример #13
0
 def test_hydrate_dehydrate_int(self):
     """int value is correctly hydrated and dehydrated"""
     wet_value = 9001
     dry_value = dehydrate_value("int", wet_value)
     self.assertEqual(hydrate_value("int", dry_value), wet_value)
Пример #14
0
 def value(self):
     if not self.dry_value and self.default_value:
         return hydrators.hydrate_value(self.python_type,
                                        self.default_value)
     else:
         return hydrators.hydrate_value(self.python_type, self.dry_value)