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
183 stars 19 forks source link

pass container args to docker; add support for mongo transactions #217

Closed ssimfukwe closed 4 months ago

ssimfukwe commented 4 months ago

in order to use mongodb transactions, the servers have to be deployed as a replica set or sharded cluster. This requires passing in additional options when docker starts. This change makes it so

Replication is turned on by passing in --replSet as a container argument. Usage would look something like this

@pytest.fixture(scope="session", autouse=True)
def pmr_mongo_config():
    return MongoConfig(
        image="mongo:7",
        root_database=$MONGO_APP_DB,
        port=27017,
        container_args=["--replSet", "rs0", "--bind_ip_all", "--oplogSize", "128"],
    )