schireson / pytest-mock-resources

Pytest Fixtures that let you actually test against external resource (Postgres, Mongo, Redshift...) dependent code.
https://pytest-mock-resources.readthedocs.io/en/latest/quickstart.html
MIT License
179 stars 19 forks source link

fix: Adjust moto fixtures to work correctly with scopes and to propag… #193

Closed DanCardin closed 1 year ago

DanCardin commented 1 year ago

…ate credentials down directly.

Unfortunately this contains a breaking change from the use of the pmr_moto_credentials fixture (removed by this PR), switching to <fixturename>.pmr_credentials, which more closely resembles the interface the rest of the fixtures expose.

i.e.


from pytest_mock_resources.fixture.moto import Session, Credentials

def test_foo(moto: Session, pmr_moto_credentials: Credentials):
    endpoint_url = pmr_moto_credentials.endpoint_url
# ->
def test_foo(moto: Session):
    endpoint_url = moto.pmr_credentials.endpoint_url

The prior interface did/does not play well with different scoping settings, nor does it play well with fixture-local options to the client/resource functions (like `region_name`).

Given the lack of recency of the moto feature and lack of evidence of existing use, the fact that the prior interface was badly designed (non-functional with anything but function scope), and the simplicity of the conversion, the version bump will be a minor release.
coveralls commented 1 year ago

Pull Request Test Coverage Report for Build 5533933721


Files with Coverage Reduction New Missed Lines %
src/pytest_mock_resources/container/base.py 2 82.27%
src/pytest_mock_resources/compat/init.py 4 81.08%
<!-- Total: 6 -->
Totals Coverage Status
Change from base Build 5215975220: -0.3%
Covered Lines: 1385
Relevant Lines: 1516

💛 - Coveralls