コード例 #1
0
ファイル: testsuite.py プロジェクト: tmaxter/stoq
def bootstrap_suite(address=None,
                    dbname=None,
                    port=5432,
                    username=None,
                    password=u"",
                    station_name=None,
                    quick=False):
    """
    Test.
    :param address:
    :param dbname:
    :param port:
    :param username:
    :param password:
    :param station_name:
    :param quick:
    """

    empty = provide_database_settings(dbname,
                                      address,
                                      port,
                                      username,
                                      password,
                                      create=not quick)

    # Reset the user settings (loaded from ~/.stoq/settings), so that user
    # preferences don't affect the tests.
    settings = get_settings()
    settings.reset()

    if quick and not empty:
        provide_utilities(station_name)
        return

    # XXX: Why clearing_cache if initialize_system will drop the
    # database?!
    ParameterAccess.clear_cache()

    initialize_system(testsuite=True, force=True)

    # Commit before trying to apply patches which requires an exclusive lock
    # to all tables.
    _enable_plugins()
    ensure_admin_user(u"")
    create(utilities=True)
コード例 #2
0
ファイル: domaintest.py プロジェクト: qman1989/stoq
    def count_tracer(self):
        """Count the number of statements that are executed during
        a specific context, this is useful for local performance testing
        where the number of statements shouldn't increase for a specific
        operation.

        For this to behave consistently when running one test or many tests,
        it will clear common caches before starting, so the number in here
        will be higher than in the actual application.
        """
        from stoqlib.lib.parameters import ParameterAccess
        ParameterAccess.clear_cache()
        self.store.flush()
        self.store.invalidate()

        tracer = StoqlibTestsuiteTracer()
        tracer.install()
        yield tracer
        tracer.remove()
コード例 #3
0
    def count_tracer(self):
        """Count the number of statements that are executed during
        a specific context, this is useful for local performance testing
        where the number of statements shouldn't increase for a specific
        operation.

        For this to behave consistently when running one test or many tests,
        it will clear common caches before starting, so the number in here
        will be higher than in the actual application.
        """
        from stoqlib.lib.parameters import ParameterAccess
        ParameterAccess.clear_cache()
        self.store.flush()
        self.store.invalidate()

        tracer = StoqlibTestsuiteTracer()
        tracer.install()
        yield tracer
        tracer.remove()
コード例 #4
0
ファイル: testsuite.py プロジェクト: rosalin/stoq
def bootstrap_suite(address=None, dbname=None, port=5432, username=None,
                    password=u"", station_name=None, quick=False):
    """
    Test.
    :param address:
    :param dbname:
    :param port:
    :param username:
    :param password:
    :param station_name:
    :param quick:
    """

    # This will only be required when we use uuid.UUID instances
    # for UUIDCol
    #import psycopg2.extras
    #psycopg2.extras.register_uuid()

    empty = provide_database_settings(dbname, address, port, username, password,
                                      create=not quick)

    # Reset the user settings (loaded from ~/.stoq/settings), so that user
    # preferences don't affect the tests.
    settings = get_settings()
    settings.reset()

    if quick and not empty:
        provide_utilities(station_name)
        _enable_plugins()
        return

    # XXX: Why clearing_cache if initialize_system will drop the
    # database?!
    ParameterAccess.clear_cache()

    initialize_system(testsuite=True, force=True)

    # Commit before trying to apply patches which requires an exclusive lock
    # to all tables.
    _enable_plugins()
    ensure_admin_user(u"")
    create(utilities=True)