Skip to content

Commit

Permalink
RM-124: Trying to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
naswierczek committed Feb 14, 2024
1 parent 70078f8 commit 3b1f4ef
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 12 deletions.
6 changes: 3 additions & 3 deletions records_mover/creds/base_creds.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self,
str,
None] = PleaseInfer.token,
default_airbyte_creds: Union[PleaseInfer,
str,
Dict[str, Any],
None] = PleaseInfer.token) -> None:
self._default_db_creds_name = default_db_creds_name
self._default_aws_creds_name = default_aws_creds_name
Expand Down Expand Up @@ -271,10 +271,10 @@ def default_scratch_gcs_url(self) -> Optional[str]:
self._scratch_gcs_url = self._infer_scratch_gcs_url()
return self._scratch_gcs_url

def _infer_airbyte_creds(self) -> Optional[str]:
def _infer_airbyte_creds(self) -> Dict[str, Any]:
raise NotImplementedError

def airbyte(self) -> dict:
def airbyte(self) -> Optional[Dict[str, Any]]:
if self._default_airbyte_creds is PleaseInfer.token:
self._default_airbyte_creds = self._infer_airbyte_creds()
return self._default_airbyte_creds
6 changes: 3 additions & 3 deletions records_mover/creds/creds_via_env.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import os
import base64
import json
from typing import Iterable, Optional
from typing import Iterable, Optional, Any, Dict
from .base_creds import BaseCreds
from typing import TYPE_CHECKING
from db_facts.db_facts_types import DBFacts
Expand All @@ -13,9 +13,9 @@


class CredsViaEnv(BaseCreds):
def _infer_airbyte_creds(self) -> Optional[str]:
def _infer_airbyte_creds(self) -> Dict[str, Any]:
if 'AIRBYTE_CONNECTION' not in os.environ:
return None
return {}
return {
'user': 'username',
'host': 'host',
Expand Down
3 changes: 2 additions & 1 deletion records_mover/records/airbyte/airbyte.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ class AirbyteEngine:
General thoughts, maybe this should encapsulate making a request to airbyte
Thus we'd have a method for making a request which'd know how to authenticate
"""
session: Session

def __init__(self, session: Session = None):
def __init__(self, session: Session):
"""
Args:
session: Optional records mover Session, exposed for testing.
Expand Down
10 changes: 5 additions & 5 deletions records_mover/records/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def job_fn(raw_config: Dict[str, Any]) -> None:
return job_fn


def build_parser() -> argparse.ArgumentParser:
def build_parser(bootstrap_session: Session) -> argparse.ArgumentParser:
# skip in-memory sources/targets like dataframes that don't make
# sense from the command-line
source_method_name_by_cli_name = {
Expand Down Expand Up @@ -85,8 +85,6 @@ def build_parser() -> argparse.ArgumentParser:
parser.add_argument('-hc', '--healthcheck', action='store_true', required=False, help='Returns health of the '
'configured airbyte instance')
subparsers = parser.add_subparsers(help='subcommand_help')
from records_mover import Session
bootstrap_session = Session()

for source in sources:
for target in targets:
Expand All @@ -112,12 +110,14 @@ def main() -> None:
warnings.filterwarnings("ignore",
"Your application has authenticated using end user credentials")

parser = build_parser()
from records_mover import Session
session = Session()
parser = build_parser(session)
args = parser.parse_args()
raw_config = vars(args)
func = getattr(args, 'func', None)
if args.healthcheck:
engine = AirbyteEngine()
engine = AirbyteEngine(session)
result = engine.healthcheck()
if result:
print("Airbyte Status: OK!")
Expand Down
Empty file.
2 changes: 2 additions & 0 deletions types/stubs/requests/__init__.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def get(url, params=None, **kwargs):
...

0 comments on commit 3b1f4ef

Please sign in to comment.