testcontainers / testcontainers-python

Testcontainers is a Python library that providing a friendly API to run Docker container. It is designed to create runtime environment to use during your automatic tests.
https://testcontainers-python.readthedocs.io/en/latest/
Apache License 2.0
1.54k stars 281 forks source link

feat(core): Added Generic module #612

Closed Tranquility2 closed 3 months ago

Tranquility2 commented 3 months ago

As part of the effort described, detailed and presented on https://github.com/testcontainers/testcontainers-python/pull/559 This is the third PR (out of 4) that should provide all the groundwork to support containers running a server.

As discussed on #595 this PR aims to refactor the ServerContainer under a new dedicated module called "generic". image

The idea is that this module could include multiple generic implementations such as server.py with the proper documentation and examples to allow users simpler usage and QOL. This PR adds the original FastAPI implementation as a simple doc example, I think this aligns better following #595

Next in line is feat(core): Added AWS Lambda module

Based on the work done on https://github.com/testcontainers/testcontainers-python/pull/585 and #595 Expended from issue https://github.com/testcontainers/testcontainers-python/issues/83


Please note an extra commit is included to simulate the relations when importing between and with other modules.

Tranquility2 commented 3 months ago

I'll remove the extra commit `Test module import' once we feel the PR is ready

codecov[bot] commented 3 months ago

Codecov Report

Attention: Patch coverage is 0% with 1 line in your changes missing coverage. Please review.

Please upload report for BASE (main@3519f4b). Learn more about missing BASE report.

:exclamation: Current head ccf45af differs from pull request most recent head 30d3172

Please upload reports for the commit 30d3172 to get more accurate results.

Files Patch % Lines
core/testcontainers/core/generic.py 0.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #612 +/- ## ======================================= Coverage ? 76.26% ======================================= Files ? 11 Lines ? 573 Branches ? 83 ======================================= Hits ? 437 Misses ? 110 Partials ? 26 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

alexanderankin commented 3 months ago

I actually really love the test module import, if it can be test_module_import instead of just one word, or maybe a different name, this is really useful for the future as a proof that it is working. I think it should be enforced with CI.

I kind of want to think about this some more before merging, as its a fairly major change. but one that I think make sense.

i have to double check what we are doing with the httpx in the poetry files because afaik, you should not need to be adding it to the extras. we already depend on urllib3, we should just do the same to httpx, if we are doing to rely on it this heavily.

Tranquility2 commented 3 months ago

I'll be happy to add test_module_import but think it should go as a separate commit right?