Exemplo n.º 1
0
    def to_dict(self):
        """Returns a dict with the representation of this task configuration object."""

        properties = find_class_properties(self.__class__)
        config = {
            name: self.__getattribute__(name) for name, _ in properties
        }
        return config
    def test_find_class_properties(self):
        """Test if properties are found in a class"""

        properties = find_class_properties(PropertiesClass)
        self.assertEqual(len(properties), 2)

        p = properties[0]
        self.assertEqual(p[0], 'my_property')
        self.assertIsInstance(p[1], property)

        p = properties[1]
        self.assertEqual(p[0], 'readonly_property')
        self.assertIsInstance(p[1], property)
    def test_find_no_properties(self):
        """Test if nothing is found in an object with no properties"""

        properties = find_class_properties(NoPropertiesClass())
        self.assertEqual(len(properties), 0)