-
Notifications
You must be signed in to change notification settings - Fork 64
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
feature: integrate pytest-molecule
plugin
#124
Conversation
* Add python 3.8 back * Fix requirements * Remove noqa, ruff 38 * 3.8 for GHA
logger = logging.getLogger(__name__) | ||
|
||
|
||
def pytest_collection_modifyitems(config, items): |
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 can just drop this
src/pytest_ansible/molecule.py
Outdated
# selinux bindings are not guaranteed to fail molecule execution. | ||
|
||
|
||
def pytest_collect_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.
this should be put in the main plugin 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.
(you'll need to import MoleculeFile in there)
@@ -174,6 +200,9 @@ def pytest_configure(config): | |||
start_path = config.invocation_params.dir | |||
inject(start_path) | |||
|
|||
if config.option.molecule: |
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.
we don't need this since we're moving collect files into the main plugin 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.
Are there any tests we can pull over from the pytest-molecule repo to show this working?
from the pytest-molecule repo, there are no exact tests that we can pull over actually as all are support test setups written in yaml, should we write our own tests to show the actual working? |
@@ -0,0 +1,15 @@ | |||
*********************************** | |||
Delegated driver installation guide |
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 root molecule directory supported to be here?
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.
ah looks like it's for the tests....... It can be moved to a /tests/fixtures/molecule directory
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.
We can move this in a seperate PR
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.
so should I move it or not in this PR?
@@ -0,0 +1,83 @@ | |||
import os |
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 this directory be called molecule?
MoleculeFile = None | ||
|
||
|
||
class TestMoleculeItem: |
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.
these don't need to be classes, they can just be global functions in the file
mocker.patch("MoleculeFile.path", Mock(return_value="mock/path")) | ||
mocker.patch("os.getcwd", Mock(return_value="mock/cwd")) | ||
molecule_file = MoleculeFile() | ||
assert str(molecule_file) == "mock/path" |
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 looks odd.............
"Test Generator to collect the test" | ||
|
||
@pytest.fixture() | ||
def test_collect(self, mocker): # noqa: PT004 |
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 also please confirm these tests are running via tox in the github action?
.config/requirements.txt
Outdated
# by the following command: | ||
# | ||
# pip-compile --extra=docs --extra=test --no-annotate --output-file=.config/requirements.txt --resolver=backtracking --strip-extras --unsafe-package=ruamel-yaml-clib pyproject.toml | ||
# | ||
ansible-core==2.15.0 |
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 this is why py3.7 and 3.8 are failing, core is pinned here, but to a version that isn't compatible with 3.7 or 3.8
@@ -0,0 +1,15 @@ | |||
*********************************** | |||
Delegated driver installation guide |
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.
We can move this in a seperate PR
for more information, see https://pre-commit.ci
* Fix for ansible 2.9 * Else not needed
@Ruchip16 please remove the virtual environment folder |
yes, this PR got messed up with commits, creating a new PR with specific changes needed! |
Related to: #70, #73, #145
Added the pytest-molecule code in a new file called molecule and introducing command line args
--molecule
that tirggers thepytest-molecule
plugin, creating a draft PR as the work is in progress and I need some suggestions on it