Skip to content

Commit c512eb1

Browse files
committed
MHR API verify new CI script.
Signed-off-by: Doug Lovett <doug@diamante.ca>
1 parent dde71c3 commit c512eb1

File tree

5 files changed

+17
-475
lines changed

5 files changed

+17
-475
lines changed

mhr-api/devops/vaults.gcp.env

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,3 @@ DOC_SERVICE_CONFIG='op://ppr/$APP_ENV/mhr-api/DOC_SERVICE_CONFIG'
4646
GUNICORN_PROCESSES="op://ppr/$APP_ENV/mhr-api/GUNICORN_PROCESSES"
4747
GUNICORN_THREADS="op://ppr/$APP_ENV/mhr-api/GUNICORN_THREADS"
4848
REPORT_VERSION="op://ppr/$APP_ENV/mhr-api/REPORT_VERSION"
49-
REPORT_API_AUDIENCE=op://API/$APP_ENV/report-api-gotenberg/REPORT_API_GOTENBERG_URL"

mhr-api/src/mhr_api/__init__.py

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,7 @@
3434
from mhr_api.utils.auth import jwt
3535
from mhr_api.utils.logging import logger, setup_logging
3636

37-
setup_logging(
38-
os.path.join(os.path.abspath(os.path.dirname(__file__)), "logging.yaml")
39-
) # important to do this first
37+
setup_logging(os.path.join(os.path.abspath(os.path.dirname(__file__)), "logging.yaml")) # important to do this first
4038

4139

4240
def create_app(service_environment=APP_RUNNING_ENVIRONMENT, **kwargs):
@@ -49,16 +47,12 @@ def create_app(service_environment=APP_RUNNING_ENVIRONMENT, **kwargs):
4947

5048
db.init_app(app)
5149
Migrate(app, db)
52-
if (
53-
app.config.get("DEPLOYMENT_ENV", "") == "unitTesting"
54-
): # CI only run upgrade for unit testing.
50+
if app.config.get("DEPLOYMENT_ENV", "") == "testing": # CI only run upgrade for unit testing.
5551
logger.info("Running db upgrade.")
5652
with app.app_context():
5753
upgrade(directory="migrations", revision="head", sql=False, tag=None)
5854
# Alembic has it's own logging config, we'll need to restore our logging here.
59-
setup_logging(
60-
os.path.join(os.path.abspath(os.path.dirname(__file__)), "logging.yaml")
61-
)
55+
setup_logging(os.path.join(os.path.abspath(os.path.dirname(__file__)), "logging.yaml"))
6256
logger.info("Finished db upgrade.")
6357
else:
6458
logger.info("Logging, migrate set up.")
@@ -112,9 +106,7 @@ def setup_test_data():
112106
"""Load unit test data in the dev/local environment. Delete all existing test data as a first step."""
113107
try:
114108
test_path = os.getcwd()
115-
logger.info(
116-
f"Executing DB scripts to create test data from test data dir {test_path}..."
117-
)
109+
logger.info(f"Executing DB scripts to create test data from test data dir {test_path}...")
118110
# execute_script(db.session, os.path.join(test_path, "test_data/postgres_test_reset.sql"))
119111
execute_script(db.session, "test_data/postgres_create_first.sql")
120112
filenames = os.listdir(os.path.join(test_path, "test_data/postgres_data_files"))
@@ -126,16 +118,12 @@ def setup_test_data():
126118
)
127119
# execute_script(db.session, "test_data/postgres_test_reset_ppr.sql")
128120
execute_script(db.session, "test_data/postgres_create_first_ppr.sql")
129-
filenames = os.listdir(
130-
os.path.join(os.getcwd(), "test_data/postgres_data_files_ppr")
131-
)
121+
filenames = os.listdir(os.path.join(os.getcwd(), "test_data/postgres_data_files_ppr"))
132122
sorted_names = sorted(filenames)
133123
for filename in sorted_names:
134124
execute_script(
135125
db.session,
136-
os.path.join(
137-
os.getcwd(), ("test_data/postgres_data_files_ppr/" + filename)
138-
),
126+
os.path.join(os.getcwd(), ("test_data/postgres_data_files_ppr/" + filename)),
139127
)
140128
except Exception as err: # pylint: disable=broad-except # noqa F841;
141129
logger.error(f"setup_test_data failed: {str(err)}")

mhr-api/src/mhr_api/config.py

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,7 @@ class Config: # pylint: disable=too-few-public-methods
101101
if DB_UNIX_SOCKET := os.getenv("DATABASE_UNIX_SOCKET", None):
102102
SQLALCHEMY_DATABASE_URI = f"postgresql+psycopg2://{DB_USER}:{DB_PASSWORD}@/{DB_NAME}?host={DB_UNIX_SOCKET}"
103103
else:
104-
SQLALCHEMY_DATABASE_URI = (
105-
f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
106-
)
104+
SQLALCHEMY_DATABASE_URI = f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
107105

108106
# Connection pool settings
109107
DB_MIN_POOL_SIZE = os.getenv("DATABASE_MIN_POOL_SIZE", "2")
@@ -142,9 +140,7 @@ class Config: # pylint: disable=too-few-public-methods
142140
# ACCOUNT_SVC_TIMEOUT = os.g
143141

144142
# DB Query limits on result set sizes
145-
ACCOUNT_REGISTRATIONS_MAX_RESULTS = os.getenv(
146-
"ACCOUNT_REGISTRATIONS_MAX_RESULTS", "100"
147-
)
143+
ACCOUNT_REGISTRATIONS_MAX_RESULTS = os.getenv("ACCOUNT_REGISTRATIONS_MAX_RESULTS", "100")
148144
ACCOUNT_DRAFTS_MAX_RESULTS = os.getenv("ACCOUNT_DRAFTS_MAX_RESULTS", "1000")
149145
ACCOUNT_SEARCH_MAX_RESULTS = os.getenv("ACCOUNT_SEARCH_MAX_RESULTS", "1000")
150146

@@ -159,45 +155,31 @@ class Config: # pylint: disable=too-few-public-methods
159155

160156
# Google APIs and cloud storage
161157
GOOGLE_DEFAULT_SA = os.getenv("GOOGLE_DEFAULT_SA")
162-
GCP_CS_SA_SCOPES = os.getenv(
163-
"GCP_CS_SA_SCOPES", "https://www.googleapis.com/auth/cloud-platform"
164-
)
158+
GCP_CS_SA_SCOPES = os.getenv("GCP_CS_SA_SCOPES", "https://www.googleapis.com/auth/cloud-platform")
165159
# Storage of search reports
166160
GCP_CS_BUCKET_ID = os.getenv("GCP_CS_BUCKET_ID", "mhr_search_result_report_dev")
167161
# Storage of registration verification reports
168-
GCP_CS_BUCKET_ID_REGISTRATION = os.getenv(
169-
"GCP_CS_BUCKET_ID_REGISTRATION", "mhr_registration_report_dev"
170-
)
162+
GCP_CS_BUCKET_ID_REGISTRATION = os.getenv("GCP_CS_BUCKET_ID_REGISTRATION", "mhr_registration_report_dev")
171163
# Storage of batch reports
172164
GCP_CS_BUCKET_ID_BATCH = os.getenv("GCP_CS_BUCKET_ID_BATCH", "mhr_batch_report_dev")
173165
# Storage of service agreement terms reports
174-
GCP_CS_BUCKET_ID_TERMS = os.getenv(
175-
"GCP_CS_BUCKET_ID_TERMS", "mhr_service_agreement_dev"
176-
)
166+
GCP_CS_BUCKET_ID_TERMS = os.getenv("GCP_CS_BUCKET_ID_TERMS", "mhr_service_agreement_dev")
177167

178168
# Pub/Sub
179169
GCP_PS_PROJECT_ID = os.getenv("DEPLOYMENT_PROJECT", "eogruh-dev")
180-
GCP_PS_SEARCH_REPORT_TOPIC = os.getenv(
181-
"GCP_PS_SEARCH_REPORT_TOPIC", "mhr-search-report"
182-
)
183-
GCP_PS_REGISTRATION_REPORT_TOPIC = os.getenv(
184-
"GCP_PS_REGISTRATION_REPORT_TOPIC", "mhr-registration-report"
185-
)
170+
GCP_PS_SEARCH_REPORT_TOPIC = os.getenv("GCP_PS_SEARCH_REPORT_TOPIC", "mhr-search-report")
171+
GCP_PS_REGISTRATION_REPORT_TOPIC = os.getenv("GCP_PS_REGISTRATION_REPORT_TOPIC", "mhr-registration-report")
186172

187173
GATEWAY_URL = os.getenv("GATEWAY_URL", "https://bcregistry-dev.apigee.net")
188-
GATEWAY_LTSA_URL = os.getenv(
189-
"GATEWAY_LTSA_URL", "https://bcregistry-test.apigee.net/ltsa/api/v1"
190-
)
174+
GATEWAY_LTSA_URL = os.getenv("GATEWAY_LTSA_URL", "https://bcregistry-test.apigee.net/ltsa/api/v1")
191175
SUBSCRIPTION_API_KEY = os.getenv("SUBSCRIPTION_API_KEY")
192176
GATEWAY_API_KEY = os.getenv("GATEWAY_API_KEY")
193177

194178
# Search results data size threshold for real time reports.
195179
MAX_SIZE_SEARCH_RT: int = int(os.getenv("MAX_SIZE_SEARCH_RT", "200000"))
196180
# Default 2, set to 1 to revert to original report api client
197181
REPORT_VERSION = os.getenv("REPORT_VERSION", "2")
198-
REPORT_API_AUDIENCE = os.getenv(
199-
"REPORT_API_AUDIENCE", "https://gotenberg-p56lvhvsqa-nn.a.run.app"
200-
)
182+
REPORT_API_AUDIENCE = os.getenv("REPORT_API_AUDIENCE", "https://gotenberg-p56lvhvsqa-nn.a.run.app")
201183

202184
NOTIFY_MAN_REG_CONFIG = os.getenv("NOTIFY_MAN_REG_CONFIG")
203185
NOTIFY_LOCATION_CONFIG = os.getenv("NOTIFY_LOCATION_CONFIG")
@@ -250,9 +232,7 @@ class UnitTestingConfig(Config): # pylint: disable=too-few-public-methods
250232
DB_HOST = os.getenv("DATABASE_TEST_HOST", "")
251233
DB_PORT = os.getenv("DATABASE_TEST_PORT", "5432")
252234
# SQLALCHEMY_DATABASE_URI = f"postgresql+pg8000://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
253-
SQLALCHEMY_DATABASE_URI = (
254-
f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
255-
)
235+
SQLALCHEMY_DATABASE_URI = f"postgresql://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
256236

257237
# JWT OIDC settings
258238
# JWT_OIDC_TEST_MODE will set jwt_manager to use

mhr-api/src/mhr_api/utils/admin_validator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
from mhr_api.models import MhrRegistration
1919
from mhr_api.models import registration_utils as reg_utils
2020
from mhr_api.models.type_tables import MhrDocumentTypes, MhrNoteStatusTypes, MhrRegistrationTypes
21-
from mhr_api.utils import validator_utils, validator_owner_utils
21+
from mhr_api.utils import validator_owner_utils, validator_utils
2222
from mhr_api.utils.logging import logger
2323

2424
NCAN_DOC_TYPES = " CAU CAUC CAUE NCON NPUB REGC REST " # Set of doc types NCAN can cancel.

0 commit comments

Comments
 (0)