-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Modify Manifester class to work with MockStub #4
Conversation
Add a class to test_manifester.py to enable requests to be sent to a MockStub version of the requests package instead of sending live requests to the API. Modify the Manifester class to use the MockStub-based requests when running unit tests. Add a helper function to generate mock HTTP response codes.
4973169
to
5dcf41c
Compare
5dcf41c
to
0996b26
Compare
This commit makes several modifications to the test harness, helper functions, and manifester itself to get the first two unit tests into a working state.
This commit adds a test for manifester's get_manifest() method, which is used to generate a manifest and write it locally. It also adds docstrings to functions in helpers.py and test_manifester.py that did not have docstrings previously.
This commit adds a test for Manifester's `delete_subscription_allocation` method and a `delete` method to the `RhsmApiStub` class to handle HTTP DELETE requests.
This commit adds a negative test for the timeout on exporting a manifest. It also modifies the return values of the mocked HTTP verb methods to reuse the same RhsmApiStub object throughout each execution, rather than returning a new RhsmApiStub object with each method call. It also modifies the manifester class and helper methods to support this change.
This commit adds a test of manifester's ability to handle the RHSM API's result pagination when attempting to retrieve all the subscription pools in an account containing more than 50 subscription pools. It also modifies the Manifester and RhsmApiStub classes to support the test.
This commit brings the mock subscription pool response data more in line with what is returned by the RHSM API in order to simplify some of the conditional logic that the Manifester class uses to process real vs mocked data.
This commit adds a test to ensure that each of the subscriptions in manifester_settings.yaml was successfully added to the subscription allocation created during a `get_manifest()` execution.
This commit adds a test to ensure that Manifester will replace an invalid sat_version value with the most recent valid sat_version. Since this test reuses the same manifest_data that was previously defined in another test, it also moves that manifest_data to a global variable.
This commit adds reworks the pre-commit hooks used by manifester. It includes changes to several files due to reformatting and other changes from black and ruff.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK on most everything. Just one request for your Ruff rules. This will require you to re-run ruff against the project.
This commit switches from using black for formatting and ruff for linting to using ruff for both of these. It also implements a more complete pyproject.toml and includes many small changes to get the project into a passing state for ruff. Additionally, it removes setup.py and setup.cfg as these are now redundant with pyproject.toml.
This pull request sets up GitHub code scanning for this repository. Once the scans have completed and the checks have passed, the analysis results for this pull request branch will appear on this overview. Once you merge this pull request, the 'Security' tab will show more code scanning analysis results (for example, for the default branch). Depending on your configuration and choice of analysis tool, future pull requests will be annotated with code scanning analysis results. For more information about GitHub code scanning, check out the documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Couple of small things
"Natural Language :: English", | ||
"Programming Language :: Python :: 3", | ||
"Programming Language :: Python :: 3.10", | ||
"Programming Language :: Python :: 3.11", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you have it in your checks, you can ad py 3.12 to this list.
tests/test_manifester.py
Outdated
@@ -11,7 +11,7 @@ | |||
manifest_data = { | |||
"log_level": "debug", | |||
"offline_token": "test", | |||
"proxies": {"https:" ""}, | |||
"proxies": {"https:"}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this meant to be a set or a dictionary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's meant to be a dictionary. Good catch, I'll correct that.
Since the manifester repo does not contain a fully populated config file, this commit switches all of the tests to use the manifest_data dictionary defined in the test_manifester.py module as the value of manifest_category when instantiating a Manifester object. It also add Python 3.12 to the list of classifiers in pyproject.toml.
Looking at the CodeQL failures, the checkout action is merging in commit 79a4b4e [1], although the most recent commit in this PR is 2af7760. I'm trying to determine why this is happening, and I'm open to suggestions if anyone has see something like this before. [1] https://github.com/SatelliteQE/manifester/actions/runs/7091796806/job/19342080413#step:2:77 |
Strange, I've not seeing that before. Are the tests passing locally? |
@JacobCallahan The change in 2bc2572 seems to have it now pulling the proper commit, although the tests are still failing in a way that they aren't locally. The tests are passing locally generally, but I'm finding there's more flakiness than I'm comfortable with when I run all the tests in the module together. I think this is a result of me making the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haven't gotten to tests yet. Mostly just being picky about constants. There's a couple other places you used these. Definitely non-blocking just stylistic.
I'm not sure if I have fully resolved the flakiness issue, but I just had three successful local runs of all the tests, so I'm moving on for now. Here's one, just for the record:
I was able to reproduce the CI failure by renaming my local |
Ok, the issue with tests failing was due to some To address the test flakiness issue, I've also changed the default |
This commit removes default values in several `get()` calls that were pulling from settings and causing the unit tests to fail in CI. It also changes the default `fail_rate` for HTTP response codes to 0 to address an issue in which a bad response code would loop permanently, causing unpredictable test flakiness.
Add a class to test_manifester.py to enable requests to be sent to a
MockStub version of the requests package instead of sending live
requests to the API. Modify the Manifester class to use the
MockStub-based requests when running unit tests. Add a helper function
to generate mock HTTP response codes.
This PR should start as a draft, as there is currently an issue with
integrating simple_retry with the RhsmApiStub class:
http://pastebin.test.redhat.com/1055597