josh-fell commented on PR #22938:
URL: https://github.com/apache/airflow/pull/22938#issuecomment-1144019156
> @josh-fell I was able to resolve the unit test failures locally by
updating the value of `dbt_cloud_conn_id` to `dbt_cloud` (the name of my
connection locally). Should I push those changes?
I don't think that will work for CI unfortunately. The test will be looking
for a connection that's accessible by the CI environment. I can see a couple
options to help resolve the failure:
1. Add a `Connection` and `db.merge_conn()` in the `setup_class()` of
`TestDbtCloudJobRunSensor` like what's in `TestDbtCloudHook`. This would ensure
a connection is always available for the test. Most straightforward to resolve
the failure.
2. Remove the `self.base_url` logic from the constructor of the
`DbtCloudHook` and implement a `cached_property` instead. This would make the
hook constructor a little cleaner IMO, but would probably warrant a little bit
of regression testing. The mock patch would skip over all of this logic and
there would be no change to the test itself.
```python
@cached_property
def base_url(self) -> str:
tenant = self.connection.schema if self.connection.schema else
"cloud"
return f"https://{tenant}.getdbt.com/api/v2/accounts/"
```
I don't have a strong opinion either way.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]