Skip to content
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

Closed
wants to merge 35 commits into from

Conversation

Ruchip16
Copy link
Member

Related to: #70, #73, #145

Added the pytest-molecule code in a new file called molecule and introducing command line args --molecule that tirggers the pytest-molecule plugin, creating a draft PR as the work is in progress and I need some suggestions on it

@Ruchip16 Ruchip16 marked this pull request as ready for review May 29, 2023 11:13
@Ruchip16 Ruchip16 requested a review from a team as a code owner May 29, 2023 11:13
@Ruchip16 Ruchip16 requested review from priyamsahoo and shatakshiiii and removed request for a team May 29, 2023 11:13
logger = logging.getLogger(__name__)


def pytest_collection_modifyitems(config, items):
Copy link
Contributor

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

# selinux bindings are not guaranteed to fail molecule execution.


def pytest_collect_file(
Copy link
Contributor

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

Copy link
Contributor

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)

src/pytest_ansible/plugin.py Show resolved Hide resolved
@@ -174,6 +200,9 @@ def pytest_configure(config):
start_path = config.invocation_params.dir
inject(start_path)

if config.option.molecule:
Copy link
Contributor

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

@Ruchip16 Ruchip16 requested a review from cidrblock June 7, 2023 18:24
Copy link
Contributor

@cidrblock cidrblock left a 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?

tests/conftest.py Show resolved Hide resolved
@Ruchip16
Copy link
Member Author

Ruchip16 commented Jun 8, 2023

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?

@Ruchip16 Ruchip16 requested a review from cidrblock June 16, 2023 11:05
@@ -0,0 +1,15 @@
***********************************
Delegated driver installation guide
Copy link
Contributor

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?

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member Author

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
Copy link
Contributor

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:
Copy link
Contributor

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"
Copy link
Contributor

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
Copy link
Contributor

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?

# 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
Copy link
Contributor

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

.vscode/settings.json Show resolved Hide resolved
@@ -0,0 +1,15 @@
***********************************
Delegated driver installation guide
Copy link
Contributor

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

@audgirka
Copy link
Contributor

audgirka commented Aug 2, 2023

@Ruchip16 please remove the virtual environment folder newenv

@Ruchip16 Ruchip16 closed this Aug 2, 2023
@Ruchip16
Copy link
Member Author

Ruchip16 commented Aug 2, 2023

@Ruchip16 please remove the virtual environment folder newenv

yes, this PR got messed up with commits, creating a new PR with specific changes needed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants