def __init__(self, parent): """ Register the class and bootstrap hooks. """ try: super(RegistryMixin, self).__init__(parent) except TypeError: super(RegistryMixin, self).__init__() Registry().register(de_hump(self.__class__.__name__), self) Registry().register_function('bootstrap_initialise', self.bootstrap_initialise) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
def test_de_hump_static(self): """ Test the de_hump function with a python string """ # GIVEN: a Class name in Camel Case string = "my_class" # WHEN: we call de_hump new_string = de_hump(string) # THEN: the new string should be converted to python format self.assertTrue(new_string == "my_class", 'The class name should have been preserved')
def de_hump_conversion_test(self): """ Test the de_hump function with a class name """ # GIVEN: a Class name in Camel Case string = "MyClass" # WHEN: we call de_hump new_string = de_hump(string) # THEN: the new string should be converted to python format self.assertTrue(new_string == "my_class", 'The class name should have been converted')
def test_de_hump_static(self): """ Test the de_hump function with a python string """ # GIVEN: a Class name in Camel Case string = "my_class" # WHEN: we call de_hump new_string = de_hump(string) # THEN: the new string should be converted to python format assert new_string == "my_class", 'The class name should have been preserved'
def __init__(self, *args, **kwargs): """ Register the class and bootstrap hooks. """ try: super().__init__(*args, **kwargs) except TypeError: super().__init__() Registry().register(de_hump(self.__class__.__name__), self) Registry().register_function('bootstrap_initialise', self.bootstrap_initialise) Registry().register_function('bootstrap_post_set_up', self.bootstrap_post_set_up)
def _create_attr(self, master, element, value): """ Create the attributes with the correct data types and name format """ reject, master, element, value = self._translate_tags(master, element, value) if reject: return field = de_hump(element) tag = master + '_' + field if field in BOOLEAN_LIST: setattr(self, tag, str_to_bool(value)) elif field in INTEGER_LIST: setattr(self, tag, int(value)) else: # make string value unicode if not isinstance(value, str): value = str(str(value), 'utf-8') # None means an empty string so lets have one. if value == 'None': value = '' setattr(self, tag, str(value).strip().lstrip())