def settings(): """Default app settings.""" settings = {} settings['sqlalchemy.url'] = database_url( os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres@localhost/htest')) return settings
def settings(): """Default app settings (conf/test.ini).""" settings = { 'sqlalchemy.url': 'postgresql://postgres@localhost/htest', } if 'TEST_DATABASE_URL' in os.environ: settings['sqlalchemy.url'] = database_url( os.environ['TEST_DATABASE_URL']) return settings
def test_database_url(): url = "postgres://postgres:1234/database" expected = "postgresql+psycopg2://postgres:1234/database" assert database_url(url) == expected
import click.testing import sqlalchemy from pyramid import testing from pyramid.request import apply_request_extensions from sqlalchemy.orm import sessionmaker from webob.multidict import MultiDict from h import db from h import form from h.settings import database_url from h._compat import text_type TEST_AUTHORITY = 'example.com' TEST_DATABASE_URL = database_url( os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres@localhost/htest')) Session = sessionmaker() class DummyFeature(object): """ A dummy feature flag looker-upper. Because we're probably testing all feature-flagged functionality, this feature client defaults every flag to *True*, which is the exact opposite of what happens outside of testing. """ def __init__(self): self.flags = {}
def get_database_url(): if "DATABASE_URL" in os.environ: return database_url(os.environ["DATABASE_URL"]) return config.get_main_option("sqlalchemy.url")
def get_database_url(): if 'DATABASE_URL' in os.environ: return database_url(os.environ['DATABASE_URL']) return config.get_main_option("sqlalchemy.url")
import deform import mock import pytest import click.testing import sqlalchemy from pyramid import testing from pyramid.request import apply_request_extensions from sqlalchemy.orm import sessionmaker from h import db from h import form from h.settings import database_url from h._compat import text_type TEST_DATABASE_URL = database_url(os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres@localhost/htest')) Session = sessionmaker() class DummyFeature(object): """ A dummy feature flag looker-upper. Because we're probably testing all feature-flagged functionality, this feature client defaults every flag to *True*, which is the exact opposite of what happens outside of testing. """ def __init__(self):
def test_database_url(): url = 'postgres://postgres:1234/database' expected = 'postgresql+psycopg2://postgres:1234/database' assert settings.database_url(url) == expected
import sqlalchemy from pyramid import testing from pyramid.request import apply_request_extensions from sqlalchemy.orm import sessionmaker from webob.multidict import MultiDict from h import db from h import models from h.settings import database_url from h._compat import text_type from tests.common.fixtures import es_client # noqa: F401 from tests.common.fixtures import init_elasticsearch # noqa: F401 TEST_AUTHORITY = "example.com" TEST_DATABASE_URL = database_url( os.environ.get("TEST_DATABASE_URL", "postgresql://postgres@localhost/htest") ) Session = sessionmaker() class DummyFeature: """ A dummy feature flag looker-upper. Because we're probably testing all feature-flagged functionality, this feature client defaults every flag to *True*, which is the exact opposite of what happens outside of testing. """
def settings(): """Default app settings.""" settings = {} settings['sqlalchemy.url'] = database_url(os.environ.get('TEST_DATABASE_URL', 'postgresql://postgres@localhost/htest')) return settings
import sqlalchemy from pyramid import testing from pyramid.request import apply_request_extensions from sqlalchemy.orm import sessionmaker from webob.multidict import MultiDict from h import db from h import models from h.settings import database_url from h._compat import text_type from tests.common.fixtures import es_client # noqa: F401 from tests.common.fixtures import init_elasticsearch # noqa: F401 TEST_AUTHORITY = "example.com" TEST_DATABASE_URL = database_url( os.environ.get("TEST_DATABASE_URL", "postgresql://postgres@localhost/htest") ) Session = sessionmaker() class DummyFeature(object): """ A dummy feature flag looker-upper. Because we're probably testing all feature-flagged functionality, this feature client defaults every flag to *True*, which is the exact opposite of what happens outside of testing. """