Skip to content

Commit

Permalink
modify test and how we setup profile
Browse files Browse the repository at this point in the history
  • Loading branch information
McKnight-42 committed Jun 14, 2024
1 parent 502d448 commit 5664c51
Showing 1 changed file with 19 additions and 16 deletions.
35 changes: 19 additions & 16 deletions tests/functional/oauth/test_oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,29 +93,32 @@ def test_snowflake_basic(self, project):


class TestSnowflakeOAuthExpiration:
profile = {
"type": "snowflake",
"threads": 4,
"account": os.getenv("SNOWFLAKE_TEST_ACCOUNT"),
"user": os.getenv("SNOWFLAKE_TEST_USER"),
"oauth_client_id": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_ID"),
"oauth_client_secret": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_SECRET"),
"token": os.getenv("SNOWFLAKE_TEST_OAUTH_REFRESH_TOKEN"),
"database": os.getenv("SNOWFLAKE_TEST_DATABASE"),
"warehouse": os.getenv("SNOWFLAKE_TEST_WAREHOUSE"),
"authenticator": "oauth",
}

@pytest.fixture(scope="class", autouse=True)
def dbt_profile_target(self):
return {
"type": "snowflake",
"threads": 4,
"account": os.getenv("SNOWFLAKE_TEST_ACCOUNT"),
"user": os.getenv("SNOWFLAKE_TEST_USER"),
"oauth_client_id": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_ID"),
"oauth_client_secret": os.getenv("SNOWFLAKE_TEST_OAUTH_CLIENT_SECRET"),
"token": os.getenv("SNOWFLAKE_TEST_OAUTH_REFRESH_TOKEN"),
"database": os.getenv("SNOWFLAKE_TEST_DATABASE"),
"warehouse": os.getenv("SNOWFLAKE_TEST_WAREHOUSE"),
"authenticator": "oauth",
}
return self.profile

@pytest.fixture(scope="class")
def models(self):
return {"model_1.sql": _MODELS__MODEL_1_SQL}

def test_token_expiration(self, project, dbt_profile_data):
def test_token_expiration(self, project):
# change token which is included in the connection_info
dbt_profile_data["test"]["outputs"]["default"]["token"] = "THIS_TOKEN_DOES_NOT_EXIST"
write_file(yaml.safe_dump(dbt_profile_data), project.profiles_dir, "profiles.yml")
project.adapter.config.credentials.token = "THIS_TOKEN_DOES_NOT_EXIST"

self.profile["token"] = "THIS_TOKEN_DOES_NOT_EXIST"

with pytest.raises(FailedToConnectError):
run_dbt(["run"], expect_pass=False)
run_dbt(["run", "--profile", self.profile], expect_pass=False)

0 comments on commit 5664c51

Please sign in to comment.