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

Rewrite test_import.py using pytest #332

Merged
merged 1 commit into from
Jan 23, 2024

Conversation

git-hyagi
Copy link
Contributor

fixes: #325

@git-hyagi git-hyagi force-pushed the pytest-refactor-import branch 2 times, most recently from 7fa8a56 to 8ff4af7 Compare January 22, 2024 11:24
Comment on lines 36 to 39
os.chdir(tmp_path)
repo_name1 = str(uuid.uuid4())
repo_name2 = str(uuid.uuid4())
sample_dir = Path(str(uuid.uuid4()))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
os.chdir(tmp_path)
repo_name1 = str(uuid.uuid4())
repo_name2 = str(uuid.uuid4())
sample_dir = Path(str(uuid.uuid4()))
repo_name1 = str(uuid.uuid4())
repo_name2 = str(uuid.uuid4())
sample_dir = tmp_path / str(uuid.uuid4())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hum... if we remove the os.chdir we will also need to modify the lines that depends on the dir path, right?
For example:

subprocess.run(["ostree", f"--repo={repo_name1}", "init", "--mode=archive"])

or

subprocess.run(["tar", "-cvf", f"{repo_name1}.tar", f"{repo_name1}/"])

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

really, only the last change is relevant:

sample_dir = tmp_path / str(uuid.uuid4())

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah,you maybe right. (You could probably also add a pwd to the subprocess call.)

@git-hyagi git-hyagi force-pushed the pytest-refactor-import branch from 8ff4af7 to ee55313 Compare January 22, 2024 17:57
"""A factory to generate an ostree Distribution with auto-deletion after the test run."""

def _ostree_distribution_factory(**body):
data = {"base_path": str(uuid.uuid4()), "name": str(uuid.uuid4())}
data.update(body)
return gen_object_with_cleanup(ostree_distribution_factory, data)
return gen_object_with_cleanup(ostree_distributions_api_client, data)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😨

response = http_get(urljoin(ostree_repo_path, delta_path))
assert response

monitor_task(ostree_distributions_api_client.delete(distribution.pulp_href).task)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was added in the old test case to obliterate CI errors. I think we may want to return a distribution and repository from this function to make it possible to run these tests in parallel. The test_version_removal test should handle the removal of the distribution on its own. It was the only place where we wanted to get rid of distribution to be able to delete a repository version.

@git-hyagi git-hyagi force-pushed the pytest-refactor-import branch from ee55313 to 8783451 Compare January 23, 2024 11:20
@lubosmj lubosmj merged commit b148ec4 into pulp:main Jan 23, 2024
16 checks passed
@git-hyagi git-hyagi deleted the pytest-refactor-import branch January 23, 2024 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rewrite test_import.py to pytest
3 participants