-
Notifications
You must be signed in to change notification settings - Fork 112
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
Adds a pytest local fixture for pulp_file #1728
Conversation
WARNING!!! This PR is not attached to an issue. In most cases this is not advisable. Please see our PR docs for more information about how to attach this PR to an issue. |
53adb22
to
68313f3
Compare
To run the new test you can run: |
0ad113c
to
12b6ea4
Compare
basic_file_fixture_gen_remote, | ||
file_repo, | ||
file_repo_api_client, | ||
content_file_api_client, | ||
async_monitor_task, | ||
delete_orphans_pre_post, |
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.
I started to make these pytest autouse
fixtures, but it would really take away from the explicitness of this. So I left it as-is for now.
12b6ea4
to
71a9a59
Compare
return Path(__file__).parent / "fixtures" | ||
|
||
|
||
@pytest.fixture |
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 wouldn't let me make this one scope="session"
because pytest wouldn't run with ScopeMismatch: You tried to access the 'function' scoped fixture 'aiohttp_server' with a 'session' scoped request object, involved factories
.
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.
Through more discussion we decided that while it is tempting to make each fixture server a session scope, threads are light, and eventually we want to run these in parallel which would put us back into a fixture scoped webserver. So we'll leave as fixture scope now too.
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.
What's the difference between the scopes? What difference(benefit) would it make to have this function be a different scope?
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.
Session level for example causes the fixture to be run once for the whole session (all the tests) so that data is cached and read from heavily. Other fixtures though we want to be per-test, e.g. the webservers themselves (and all the fixtures that support those). https://docs.pytest.org/en/latest/how-to/fixtures.html#scope-sharing-fixtures-across-classes-modules-packages-or-session
f6330c3
to
e0e642a
Compare
c6bdf81
to
5f4b3d4
Compare
806e460
to
316e1f6
Compare
@@ -0,0 +1 @@ | |||
from .conftest_pulp_file import * # noqa |
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.
I think we should require the pulp-smash parts here:
https://pytest.org/en/latest/how-to/plugins.html#requiring-loading-plugins-in-a-test-module-or-conftest-file
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.
Maybe, or we could just move that code here and avoid the import. The idea here was to organize the code we deliver into various submodules that then import here. It looks strange with just one of them though. Should I move the code from conftest_pulp_file
here or leave as is?
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.
I guess the only other imports here would be pulpcore related, maybe they could be useful.
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.
I'm not talking about imports. I mean
pytest_plugins = ("pulp_smash.pulp3.pytest_plugin",)
and i keep wondering how it can even work without it.
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.
Yeah it's confusing, but this installation uses the entrypoint method. That is in the setup.py now.
5837577
to
5383e74
Compare
Alright I think these achieve everything I'm happy with so I'm going to undraft it and leave a few comments for reviewers. |
4121832
to
e460884
Compare
e460884
to
5a301da
Compare
) | ||
|
||
|
||
def test_ondemand_to_immediate_sync( |
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.
This was the original test, just now rewritten.
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.
Can you move the original class docs string here? Also, I know the function names are pretty descriptive, but do you think they deserve doc strings as well? I'm surprised the linter didn't throw a fit over the absence.
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.
I can add some docstrings. Also I'd like to update the content for the test that was rewritten. Let me do some of that.
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.
I added some. I try to keep them short but clear.
|
||
|
||
@pytest.fixture | ||
def file_fixture_gen_remote_ssl( |
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.
This is the fixture I expect most tests to use.
return Path(__file__).parent / "fixtures" | ||
|
||
|
||
@pytest.fixture |
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.
What's the difference between the scopes? What difference(benefit) would it make to have this function be a different scope?
@@ -0,0 +1 @@ | |||
from .conftest_pulp_file import * # noqa |
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.
I guess the only other imports here would be pulpcore related, maybe they could be useful.
) | ||
|
||
|
||
def test_http_sync_ssl_tls_validation_defaults_to_on( |
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.
How does this validate that tls validation is defaulted to on?
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.
Because the remote it constructs does not specify it (that's the default part) yet it's connecting to a TLS context that is presenting a cert that will not be trusted without additional CA configuration.
assert len(requests_record) == 1 | ||
assert requests_record[0].path == "/basic/PULP_MANIFEST" |
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.
👍
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.
Yeah this interface is so much better. Big thanks to @mdellweg for suggesting we do it this way.
49116f2
to
33e8a72
Compare
Required PR: pulp/pulp-smash#1262 closes #9623
33e8a72
to
5dfb7d1
Compare
@@ -0,0 +1 @@ | |||
from .conftest_pulp_file import * # noqa |
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.
I'm not talking about imports. I mean
pytest_plugins = ("pulp_smash.pulp3.pytest_plugin",)
and i keep wondering how it can even work without it.
Required PR: pulp/pulp-smash#1262
closes #9623