Example #1
0
    def setUp(self):
        self.config = testing.setUp(settings=self.settings)
        archive_settings = {archive_config.CONNECTION_STRING: self.db_conn_str}
        archive_initdb(archive_settings)
        from cnxpublishing.db import initdb

        initdb(self.db_conn_str)
Example #2
0
 def setUp(self):
     archive_settings = {
         archive_config.CONNECTION_STRING: self.db_conn_str,
         }
     archive_initdb(archive_settings)
     from ..db import initdb
     initdb(self.db_conn_str)
     self.config = testing.setUp(settings=self.settings)
Example #3
0
def install_intercept():
    """Initializes both the archive and publishing applications.
    Then this will register intercepts for both applications using
    the configuration setting found in the authoring config file.
    This sets up the example data found in cnx-archive.
    Any previously initialized data will be lost.
    Therefore, it is a good idea to only initialize the applications
    during testcase class setup (i.e. setUpClass).
    """
    settings = publishing_settings()
    authoring_settings = integration_test_settings()

    connection_string = settings[config.CONNECTION_STRING]
    # Wipe out any previous attempts.
    with psycopg2.connect(connection_string) as db_connection:
        with db_connection.cursor() as cursor:
            cursor.execute("DROP SCHEMA public CASCADE; CREATE SCHEMA public")

    # Initialize the archive database.
    archive_initdb(settings)
    # Initialize the publishing database.
    publishing_initdb(connection_string)
    with psycopg2.connect(connection_string) as db_connection:
        with db_connection.cursor() as cursor:
            filepath = config.TEST_DATA_SQL_FILE
            with open(filepath, 'r') as fb:
                cursor.execute(fb.read())

    # Make amendments to the data that are specific to the authoring tests.
    _amend_archive_data()
    _amend_publishing_data()

    # Set up the intercept for archive
    global _archive_app
    if not _archive_app:
        _archive_app = archive_main({}, **publishing_settings())

    def make_app():
        return _archive_app
    # Grab the configured archive url from the authoring config.
    host, port = _parse_url_from_settings(authoring_settings,
                                          'archive.url')
    add_wsgi_intercept(host, port, make_app)

    # Set up the intercept for publishing
    global _publishing_app
    if not _publishing_app:
        _publishing_app = publishing_main({}, **publishing_settings())

    def make_app():
        return _publishing_app
    # Grab the configured publishing url from the authoring config.
    host, port = _parse_url_from_settings(authoring_settings,
                                          'publishing.url')
    add_wsgi_intercept(host, port, make_app)
Example #4
0
def install_intercept():
    """Initializes both the archive and publishing applications.
    Then this will register intercepts for both applications using
    the configuration setting found in the authoring config file.
    This sets up the example data found in cnx-archive.
    Any previously initialized data will be lost.
    Therefore, it is a good idea to only initialize the applications
    during testcase class setup (i.e. setUpClass).
    """
    settings = publishing_settings()
    authoring_settings = integration_test_settings()

    connection_string = settings[config.CONNECTION_STRING]
    # Wipe out any previous attempts.
    with psycopg2.connect(connection_string) as db_connection:
        with db_connection.cursor() as cursor:
            cursor.execute("DROP SCHEMA public CASCADE; CREATE SCHEMA public")

    # Initialize the archive database.
    archive_initdb(settings)
    # Initialize the publishing database.
    publishing_initdb(connection_string)
    with psycopg2.connect(connection_string) as db_connection:
        with db_connection.cursor() as cursor:
            filepath = config.TEST_DATA_SQL_FILE
            with open(filepath, 'r') as fb:
                cursor.execute(fb.read())

    # Make amendments to the data that are specific to the authoring tests.
    _amend_archive_data()
    _amend_publishing_data()

    # Set up the intercept for archive
    global _archive_app
    if not _archive_app:
        _archive_app = archive_main({}, **publishing_settings())

    def make_app():
        return _archive_app

    # Grab the configured archive url from the authoring config.
    host, port = _parse_url_from_settings(authoring_settings, 'archive.url')
    add_wsgi_intercept(host, port, make_app)

    # Set up the intercept for publishing
    global _publishing_app
    if not _publishing_app:
        _publishing_app = publishing_main({}, **publishing_settings())

    def make_app():
        return _publishing_app

    # Grab the configured publishing url from the authoring config.
    host, port = _parse_url_from_settings(authoring_settings, 'publishing.url')
    add_wsgi_intercept(host, port, make_app)
Example #5
0
    def setUp(self, cursor):
        settings = testing.integration_test_settings()
        from ...config import CONNECTION_STRING
        self.db_conn_str = settings[CONNECTION_STRING]

        # Initialize database
        archive_settings = {
            archive_config.CONNECTION_STRING: self.db_conn_str,
            }
        archive_initdb(archive_settings)
        initdb(self.db_conn_str)
 def setUp(self):
     accounts_config_key = archive_config.ACCOUNTS_CONNECTION_STRING
     accounts_db_conn_str = self.settings[accounts_config_key]
     archive_settings = {
         archive_config.CONNECTION_STRING: self.db_conn_str,
         archive_config.ACCOUNTS_CONNECTION_STRING: accounts_db_conn_str,
         }
     archive_initdb(archive_settings)
     from ..db import initdb
     initdb(self.db_conn_str)
     self.config = testing.setUp(settings=self.settings)
Example #7
0
    def setUp(self):
        EPUBMixInTestCase.setUp(self)
        config = testing.setUp(settings=self.settings)
        archive_settings = {
            archive_config.CONNECTION_STRING: self.db_conn_str,
            }
        archive_initdb(archive_settings)
        from cnxpublishing.db import initdb
        initdb(self.db_conn_str)

        # Assign API keys for testing
        self.set_up_api_keys()