8000 fix(anta): Fix various issues in CSV and Markdown reporters by carl-baillargeon · Pull Request #990 · aristanetworks/anta · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(anta): Fix various issues in CSV and Markdown reporters #990

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

Merged
merged 5 commits into from
Jan 3, 2025

Conversation

carl-baillargeon
Copy link
Contributor

Description

  • Remove sorting out of the Markdown reporter
  • Added ResultManager.sort
  • Sort ResultManager stats properties by default

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have run pre-commit for code linting and typing (pre-commit run)
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes (tox -e testenv)

@gmuloc gmuloc added this to the v1.3.0 milestone Jan 2, 2025
Copy link
codspeed-hq bot commented Jan 2, 2025

CodSpeed Performance Report

Merging #990 will improve performances by 14.24%

Comparing carl-baillargeon:fix/reports (5d4bf7d) with main (b765907)

Summary

⚡ 2 improvements
✅ 20 untouched benchmarks

Benchmarks breakdown

Benchmark main carl-baillargeon:fix/reports Change
test_markdown[1-device] 9.6 ms 8.4 ms +13.33%
test_markdown[2-devices] 18.5 ms 16.2 ms +14.24%

@@ -111,6 +111,7 @@ def generate(cls, results: ResultManager, csv_filename: pathlib.Path) -> None:
csvwriter = csv.writer(
csvfile,
delimiter=",",
lineterminator="\n",
Copy link
Collaborator

Choose a reason for hiding this comment

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

hmmm are you sure this works on windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes probably not :P I was just trying to make Ansible sanity (or lint?) happy in the PyAVD PR. I will add a flag to the function signature.

Choose a reason for hiding this comment

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

Fixed in 50da83a

Comment on lines 527 to 535
# Test multiple sort fields
sorted_manager = result_manager.sort(["result", "test"])
results = sorted_manager.results
assert results[0].result == "error"
assert results[0].test == "Test3"
assert results[1].result == "failure"
assert results[1].test == "Test2"
assert results[2].result == "success"
assert results[2].test == "Test1"
Copy link
Collaborator

Choose a reason for hiding this comment

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

this does not really test the sorting on the second field - would need an extra test with same result field to check

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 50da83a. Thanks

Comment on lines 537 to 547
# Test invalid sort field
with pytest.raises(
ValueError,
match=re.escape(
"Invalid sort_by fields: ['bad_field']. Accepted fields are: ['name', 'test', 'categories', 'description', 'result', 'messages', 'custom_field']",
),
):
result_manager.sort(["bad_field"])

# Verify the method is chainable
assert isinstance(result_manager.sort(["name"]), ResultManager)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I feel like it would be easier to maintain with more granular tests rather than one big (I know it means more lines :) ) as here if the test fail we need to fo through the full test to understand whats going on

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed in 50da83a

Copy link
sonarqubecloud bot commented Jan 2, 2025

@gmuloc gmuloc merged commit 0d68318 into aristanetworks:main Jan 3, 2025
25 checks passed
@carl-baillargeon carl-baillargeon deleted the fix/reports branch March 16, 2025 19:29
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.

2 participants
0