Skip to content

Commit

Permalink
fix: dbt profile loading (#117)
Browse files Browse the repository at this point in the history
* Fix: dbt profile loading

* Remove test from load_credentials
  • Loading branch information
virvirlopez authored Mar 7, 2021
1 parent c6b70e5 commit acf19ee
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 36 deletions.
13 changes: 1 addition & 12 deletions dbt_sugar/core/task/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,25 +35,14 @@ def __init__(self, flags: FlagParser, dbt_profile: DbtProfile, config: DbtSugarC
self._dbt_profile = dbt_profile
self._sugar_config = config

# FIXME: Ask Virginia why this is here, I don't think it's needed since we already read the
# profile in main.py
def load_dbt_credentials(self) -> Dict[str, str]:
"""Method to load the DBT profile credentials."""
self._dbt_profile.read_profile()
dbt_credentials = self._dbt_profile.profile
if not dbt_credentials:
logger.info("Not able to locate DBT profile.")
exit(1)
return dbt_credentials

def run(self) -> int:
"""Main script to run the command doc"""
columns_sql = []

model = self._flags.model
schema = self._dbt_profile.profile.get("target_schema", "")

dbt_credentials = self.load_dbt_credentials()
dbt_credentials = self._dbt_profile.profile
connector = DB_CONNECTORS.get(dbt_credentials.get("type", ""))
if not connector:
logger.error("The type of connector doesn't exists.")
Expand Down
24 changes: 0 additions & 24 deletions tests/doc_task_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,30 +16,6 @@ def __init_descriptions(params=None, dbt_profile=None, config=None):
return doc_task


def test_load_dbt_credentials():
class MockFlagParser:
schema = ""

profile = DbtProfile(
flags=MockFlagParser,
profile_name="dbt_sugar_test",
target_name="snowflake",
profiles_dir=Path(FIXTURE_DIR),
)
doc_task = __init_descriptions(None, profile)
credentials = doc_task.load_dbt_credentials()
assert credentials == {
"type": "snowflake",
"account": "dummy_account",
"user": "dummy_user",
"password": "dummy_password",
"database": "dummy_database",
"target_schema": "dummy_target_schema",
"role": "dummy_role",
"warehouse": "dummy_warehouse",
}


@pytest.mark.parametrize(
"column, result",
[
Expand Down

0 comments on commit acf19ee

Please sign in to comment.