def handle_noargs(self, update, **options): for module in models.get_apps(): log.info("Creating functions for %s", module.__name__) try: create_result = create_functions(module, update=update) for status, function_cls, python_name in create_result: if status == 'CREATED': msg = "created" elif status == 'UPDATED': msg = "updated" elif status == 'EXISTS': msg = "already exists, skipping" elif status == 'FORCE_REQUIRED': msg = ( "exists with incompatible schema, which must be " "manually removed") log.info("%(python_name)s (%(function_name)s): %(msg)s" % { 'python_name': python_name, 'function_name': function_cls._meta.db_table, 'msg': msg}) except Exception, exc: if not hasattr(exc, 'function_cls'): raise log.exception("Error creating function %s (%r)", exc.python_name, exc.function_cls._meta.db_table)
def test_create_functions_from_models(self): """Create functions using the create_functions and passing the models module. """ create_result = create_functions(models) for status, _, _ in create_result: self.assertEqual(status, 'CREATED') # Now check it was created cursor_wrapper = connection.cursor() cursor = cursor_wrapper.cursor self.assertEqual(_function_exists(cursor, 'user_type'), True)