def setUp(self): from base import orm config.load_from_yaml( os.path.dirname(os.path.realpath(__file__)) + f'/../config.singleservice.yaml') config.conf['db']['database'] = f"test_{config.conf['db']['database']}" importlib.import_module('orm.models') registry.test = True orm = orm.init_orm(config.conf['db']) orm.clear_database() orm.create_db_schema() importlib.import_module('users.api.users') importlib.import_module('contacts.api.contacts') config.init_logging() self.my_app = app.make_app(debug=True) from base import store with open( os.path.dirname(os.path.realpath(__file__)) + '/../users/keys/jwt.public_key') as pubkey: store.set('users_service_public_key', pubkey.read()) config.load_private_key( os.path.dirname(os.path.realpath(__file__)) + '/../users/keys/jwt.private_key') super().setUp() registry.test_port = self.get_http_port()
def setUp(self): from base import registry, orm, app, config config.load_from_yaml(current_file_folder + f'/../config/config.{os.getenv("ENVIRONMENT", "local")}.yaml') config.conf['db']['database'] = f"test_{config.conf['db']['database']}" importlib.import_module('orm.models') registry.test = True orm = orm.init_orm(config.conf['db']) orm.clear_database() orm.create_db_schema() importlib.import_module('api.contacts') config.init_logging() self.my_app = app.make_app(debug=True) super().setUp() registry.test_port = self.get_http_port()
sys.path.append(_project_path) import base from base import orm import orm.models as models config = base.config config.load_from_yaml( os.path.dirname(os.path.realpath(__file__)) + f'/../config/config.{os.getenv("ENVIRONMENT", "local")}.yaml') db_config = config.conf['db'] # print(f'alembic: {db_config["type"]}://{db_config["username"]}:...@{db_config["host"]}:{db_config["port"]}/{db_config["database"]}') sqlalchemy_url = f'{db_config["type"]}://{db_config["username"]}:{db_config["password"]}@{db_config["host"]}:{db_config["port"]}/{db_config["database"]}' orm_builder = orm.init_orm(db_config) orm.sql_base.metadata.reflect(bind=orm_builder.orm().engine()) target_metadata = orm.sql_base.metadata # remove 'target_metadata = None' # this is the Alembic Config object, which provides # access to the values within the .ini file in use. config = context.config config.set_main_option('sqlalchemy.url', sqlalchemy_url) # Interpret the config file for Python logging. # This line sets up loggers basically. fileConfig(config.config_file_name) # add your model's MetaData object here # for 'autogenerate' support