GoogleCloudPlatform / GoogleCloudPlatform/professional-services-data-validator
Improve our data source testing by using module/package based fixtures database connections.
- Dominant language
- Python
- Stars
- 524
- Forks
- 171
- Avg merge
- 5d 15h
- Merged PRs (30d)
- 4
Description
**Is your feature request related to a problem? Please describe.**
Our data source test scripts have a lot of bloat because of using a fixture as follows
```
@mock.patch(
"data_validation.state_manager.StateManager.get_connection_config",
new=mock_get_connection_config,
)
```
What this fixture does is to provide a canned connection configuration (i.e. python dict). A better solution is to provide a database connection which we create once per module. This will a) simplify our code - since these mocks will not be needed and b) speed up our testing (since connections are not being opened/closed for each test).
**Describe the solution you'd like**
use fixture scopes - likely at a module or package level
Fixture scopes
Fixtures are created when first requested by a test, and are destroyed based on their scope:
function: the default scope, the fixture is destroyed at the end of the test.
class: the fixture is destroyed during teardown of the last test in the class.
module: the fixture is destroyed during teardown of the last test in the module.
package: the fixture is destroyed during teardown of the last test in the package where the fixture is defined, including sub-packages and sub-directories within it.
session: the fixture is destroyed at the end of the test session.
Contributor guide
Assessment
This issue has not been assessed yet.