Example #1
0
 def run(self):
     from pyoko.db.schema_update import SchemaUpdater
     models = self.find_models()
     updater = SchemaUpdater(models, self.manager.args.threads,
                             self.manager.args.force)
     updater.run()
     return updater.create_report()
Example #2
0
 def run(self):
     from pyoko.db.schema_update import SchemaUpdater
     from pyoko.conf import settings
     from importlib import import_module
     import_module(settings.MODELS_MODULE)
     registry = import_module('pyoko.model').model_registry
     updater = SchemaUpdater(registry, self.manager.args.model, self.manager.args.silent)
     updater.run()
     return updater.create_report()
Example #3
0
 def run(self):
     from pyoko.db.schema_update import SchemaUpdater
     from pyoko.conf import settings
     from importlib import import_module
     import_module(settings.MODELS_MODULE)
     registry = import_module('pyoko.model').model_registry
     updater = SchemaUpdater(
         registry,
         self.manager.args.model,
         self.manager.args.threads,
         self.manager.args.force,
     )
     updater.run()
     return updater.create_report()
Example #4
0
    def schema_update(self):
        self._get_models()
        from pyoko.db.schema_update import SchemaUpdater

        self.robot = SchemaUpdater(self.registry, self.args.bucket)
        self.robot.run()
        self.report = self.robot.create_report()
def test_create_solr_schema():
    st = Student()
    fields = st._collect_index_fields()
    result = SchemaUpdater.get_schema_fields(fields)
    if not settings.DEBUG:
        assert sorted(result) == sorted(test_data_solr_schema_debug_zero)

    else:
        assert sorted(result) == sorted(test_data_solr_schema_debug_not_zero)
Example #6
0
def test_create_solr_schema():
    st = Student()
    fields = st._collect_index_fields()
    result = SchemaUpdater.get_schema_fields(fields)
    if not settings.SOLR['store']:
        assert sorted(result) == sorted(test_data_solr_schema_debug_zero)

    else:
        assert sorted(result) == sorted(test_data_solr_schema_debug_not_zero)
    def check_migration_and_solr(self):
        """
            The model or models are checked for migrations that need to be done.
            Solr is also checked.
        """
        from pyoko.db.schema_update import SchemaUpdater
        from socket import error as socket_error
        from pyoko.conf import settings
        from importlib import import_module

        import_module(settings.MODELS_MODULE)
        registry = import_module('pyoko.model').model_registry
        models = [model for model in registry.get_base_models()]
        try:
            print(__(u"Checking migration and solr ..."))
            updater = SchemaUpdater(models, 1, False)
            updater.run(check_only=True)

        except socket_error as e:
            print(
                __(u"{0}Error not connected, open redis and rabbitmq{1}").
                format(CheckList.FAIL, CheckList.ENDC))
Example #8
0
class ManagementCommands(object):
    def __init__(self, args=None):
        self.report = ""
        self.robot = None
        if args:
            self.parse_args(args)
            getattr(self, self.args.command)()
        print(self.report)

    def parse_args(self, args):
        parser = argparse.ArgumentParser()
        subparsers = parser.add_subparsers(
            title='subcommands', description='valid subcommands',
            help='additional help')
        parser_create = subparsers.add_parser('update_schema')
        parser_create.set_defaults(command='schema_update')
        parser_create.add_argument(
            '--bucket', required=True, help='Bucket name(s) to be updated')

        parser_create = subparsers.add_parser('index_bucket')
        parser_create.set_defaults(command='index_bucket')
        parser_create.add_argument(
            '--bucket', required=True,
            help='Bucket name(s) to be indexed. (Comma separated)')
        self.args = parser.parse_args(args)

    def _get_models(self):
        import_module('tests.models')
        self.registry = import_module('pyoko.model')._registry

    def schema_update(self):
        self._get_models()
        from pyoko.db.schema_update import SchemaUpdater

        self.robot = SchemaUpdater(self.registry, self.args.bucket)
        self.robot.run()
        self.report = self.robot.create_report()
def test_create_solr_schema():
    st = Student()
    fields = st._collect_index_fields()
    result = SchemaUpdater.get_schema_fields(fields)
    assert sorted(result) == sorted(test_data_solr_schema)
Example #10
0
def test_create_solr_schema():
    st = Student()
    fields = st._collect_index_fields()
    result = SchemaUpdater.get_schema_fields(fields)
    assert sorted(result) == sorted(test_data_solr_schema)