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

feat(anta): Add initial model for docx reporting #486

Closed

Conversation

titom73
Copy link
Collaborator

@titom73 titom73 commented Dec 6, 2023

Description

Add option to generate a word document to save result from ANTA.

anta nrfu report --title TEST -o demo.docx
╭────────────────────── Settings ──────────────────────╮
│ Running ANTA tests:                                  │
│ - ANTA Inventory contains 5 devices (AsyncEOSDevice) │
│ - Tests catalog contains 12 tests                    │
╰──────────────────────────────────────────────────────╯

[15:42:21] INFO     Running ANTA tests...
[15:42:24] INFO     Cache statistics for 'spine01': 0 hits / 9 command(s) (0.00%)
           INFO     Cache statistics for 'spine02': 0 hits / 9 command(s) (0.00%)
           INFO     Cache statistics for 'leaf01': 1 hits / 12 command(s) (8.33%)
           INFO     Cache statistics for 'leaf02': 1 hits / 12 command(s) (8.33%)
           INFO     Cache statistics for 'leaf03': 1 hits / 12 command(s) (8.33%)
  • Running NRFU Tests...100% ━━━━━━━ 49/49 • 0:00:03 • 0:00:00

           INFO     creating word report under demo.docx
[15:43:45] INFO     Saving report under Projects/anta-dev/anta/demo.docx                                                                                                                                                                                                                                                            

To customize look and feel:

DEFAULT_REPORT_STYLE = DocxStyle(
    colors=Colors(
        headers_table=Color(hex="#1F618D"),
        success=Color(hex="#A9DFBF"),
        failure=Color(hex="#F5B7B1"),
        error=Color(hex="#E74C3C"),
        skipped=Color(hex="#EB984E"),
    ),
    font_colors=Colors(headers_table=Color(hex="#FFFFFF")),
    font_size_default=9,
    font_name="Arial",
    table_style="Table Grid",
    shade_errors=True,
    shade_success=False,
    shade_failure=True,
)

To customize content:

DEFAULT_REPORT_FORMAT = TextInputs(
    cover=TextCover(),
    content=[
        TextSection(index=1, header="Abstract"),
        TextSection(index=2, header="Test Description", insert="tests_description", break_after=True),
        TextSection(
            index=3,
            header="Summary per tests",
            description=["Ad minim est reprehenderit id adipisicing quis sunt minim id tempor dolore."],
            insert="summary_per_test",
            break_after=True,
        ),
        TextSection(
            index=4,
            header="Tests per device",
            description=["Ad minim est reprehenderit id adipisicing quis sunt minim id tempor dolore."],
            insert="tests_per_device",
        ),
    ],
)

At the end, we should have a loader from YAML to allow end-user to customize report from CLI

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)

Copy link
Contributor

github-actions bot commented Dec 8, 2023

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Copy link
Contributor

github-actions bot commented Dec 8, 2023

Conflicts have been resolved. A maintainer will review the pull request shortly.

@titom73 titom73 added framework-enhancement New feature or request Anta CLI All things around CLI labels Dec 8, 2023
@gmuloc gmuloc added this to the v1.1.0 milestone Apr 12, 2024
Copy link
Contributor

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Anta CLI All things around CLI framework-enhancement New feature or request state: conflict
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants