{"id":27286534,"url":"https://github.com/netascode/nac-test","last_synced_at":"2025-07-21T03:33:13.456Z","repository":{"id":62592047,"uuid":"500139260","full_name":"netascode/nac-test","owner":"netascode","description":"A CLI tool to render and execute Robot Framework tests using Jinja templating.","archived":false,"fork":false,"pushed_at":"2025-06-19T05:35:25.000Z","size":1131,"stargazers_count":6,"open_issues_count":7,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-06-29T17:15:27.340Z","etag":null,"topics":["iac","jinja","nac","netascode","pabot","robot","test"],"latest_commit_sha":null,"homepage":"https://github.com/netascode/nac-test","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/netascode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-06-05T15:42:35.000Z","updated_at":"2025-05-12T15:32:29.000Z","dependencies_parsed_at":"2023-11-23T20:11:20.075Z","dependency_job_id":"85948c61-76b9-45b9-a7a5-b44f7d76ac32","html_url":"https://github.com/netascode/nac-test","commit_stats":null,"previous_names":["netascode/nac-test","netascode/iac-test"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/netascode/nac-test","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnac-test","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnac-test/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnac-test/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnac-test/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/netascode","download_url":"https://codeload.github.com/netascode/nac-test/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/netascode%2Fnac-test/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266235438,"owners_count":23897180,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["iac","jinja","nac","netascode","pabot","robot","test"],"created_at":"2025-04-11T19:42:01.409Z","updated_at":"2025-07-21T03:33:13.439Z","avatar_url":"https://github.com/netascode.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Tests](https://github.com/netascode/nac-test/actions/workflows/test.yml/badge.svg)](https://github.com/netascode/nac-test/actions/workflows/test.yml)\n![Python Support](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-informational \"Python Support: 3.10, 3.11, 3.12, 3.13\")\n\n# nac-test\n\nA CLI tool to render and execute [Robot Framework](https://robotframework.org/) tests using [Jinja](https://jinja.palletsprojects.com/) templating. Combining Robot's language agnostic syntax with the flexibility of Jinja templating allows dynamically rendering a set of test suites from the desired infrastructure state expressed in YAML syntax.\n\n```shell\n$ nac-test -h\n\n Usage: nac-test [OPTIONS]                                                                                                                                    \n                                                                                                                                                              \n A CLI tool to render and execute Robot Framework tests using Jinja templating.                                                                               \n                                                                                                                                                              \n╭─ Options ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮\n│ *  --data         -d      PATH                                 Path to data YAML files. [env var: NAC_TEST_DATA] [default: None] [required]                │\n│ *  --templates    -t      DIRECTORY                            Path to test templates. [env var: NAC_TEST_TEMPLATES] [default: None] [required]            │\n│ *  --output       -o      DIRECTORY                            Path to output directory. [env var: NAC_TEST_OUTPUT] [default: None] [required]             │\n│    --filters      -f      DIRECTORY                            Path to Jinja filters. [env var: NAC_TEST_FILTERS] [default: None]                          │\n│    --tests                DIRECTORY                            Path to Jinja tests. [env var: NAC_TEST_TESTS] [default: None]                              │\n│    --include      -i      TEXT                                 Selects the test cases by tag (include). [env var: NAC_TEST_INCLUDE]                        │\n│    --exclude      -e      TEXT                                 Selects the test cases by tag (exclude). [env var: NAC_TEST_EXCLUDE]                        │\n│    --render-only                                               Only render tests without executing them. [env var: NAC_TEST_RENDER_ONLY]                   │\n│    --dry-run                                                   Dry run flag. See robot dry run mode. [env var: NAC_TEST_DRY_RUN]                           │\n│    --verbosity    -v      [DEBUG|INFO|WARNING|ERROR|CRITICAL]  Verbosity level. [env var: NAC_VALIDATE_VERBOSITY] [default: WARNING]                       │\n│    --version                                                   Display version number.                                                                     │\n│    --help                                                      Show this message and exit.                                                                 │\n╰────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯\n```\n\nAll data from the YAML files (`--data` option) will first be combined into a single data structure which is then provided as input to the templating process. Each template in the `--templates` path will then be rendered and written to the `--output` path. If the `--templates` path has subfolders, the folder structure will be retained when rendering the templates.\n\nAfter all templates have been rendered [Pabot](https://pabot.org/) will execute all test suites in parallel and create a test report in the `--output` path. The `--skiponfailure non-critical` argument will be used by default, meaning all failed tests with a `non-critical` tag will show up as \"skipped\" instead of \"failed\" in the final test report.\n\n## Installation\n\nPython 3.10+ is required to install `nac-test`. Don't have Python 3.10 or later? See [Python 3 Installation \u0026 Setup Guide](https://realpython.com/installing-python/).\n\n`nac-test` can be installed in a virtual environment using `pip`:\n\n```shell\npip install nac-test\n```\n\nThe following Robot libraries are installed with `nac-test`:\n\n- [RESTinstance](https://github.com/asyrjasalo/RESTinstance)\n- [Requests](https://github.com/MarketSquare/robotframework-requests)\n- [JSONLibrary](https://github.com/robotframework-thailand/robotframework-jsonlibrary)\n\nAny other libraries can of course be added via `pip`.\n\n## Ansible Vault Support\n\nValues in YAML files can be encrypted using [Ansible Vault](https://docs.ansible.com/ansible/latest/user_guide/vault.html). This requires Ansible (`ansible-vault` command) to be installed and the following two environment variables to be defined:\n\n```\nexport ANSIBLE_VAULT_ID=dev\nexport ANSIBLE_VAULT_PASSWORD=Password123\n```\n\n`ANSIBLE_VAULT_ID` is optional, and if not defined will be omitted.\n\n## Additional Tags\n\n### Reading Environment Variables\n\nThe `!env` YAML tag can be used to read values from environment variables.\n\n```yaml\nroot:\n  name: !env VAR_NAME\n```\n\n## Example\n\n`data.yaml` located in `./data` folder:\n\n```yaml\n---\nroot:\n  children:\n    - name: ABC\n      param: value\n    - name: DEF\n      param: value\n```\n\n`test1.robot` located in `./templates` folder:\n\n```\n*** Settings ***\nDocumentation   Test1\n\n*** Test Cases ***\n{% for child in root.children | default([]) %}\n\nTest {{ child.name }}\n    Should Be Equal   {{ child.param }}   value\n{% endfor %}\n```\n\nAfter running `nac-test` with the following parameters:\n\n```shell\nnac-test --data ./data --templates ./templates --output ./tests\n```\n\nThe following rendered Robot test suite can be found in the `./tests` folder:\n\n```\n*** Settings ***\nDocumentation   Test1\n\n*** Test Cases ***\n\nTest ABC\n    Should Be Equal   value   value\n\nTest DEF\n    Should Be Equal   value   value\n```\n\nAs well as the test results and reports:\n\n```shell\n$ tree -L 1 tests\ntests\n├── log.html\n├── output.xml\n├── pabot_results\n├── report.html\n├── test1.robot\n└── xunit.xml\n```\n\n## Custom Jinja Filters\n\nCustom Jinja filters can be used by providing a set of Python classes where each filter is implemented as a separate `Filter` class in a `.py` file located in the `--filters` path. The class must have a single attribute named `name`, the filter name, and a `classmethod()` named `filter` which has one or more arguments. A sample filter can be found below.\n\n```python\nclass Filter:\n    name = \"filter1\"\n\n    @classmethod\n    def filter(cls, data):\n        return str(data) + \"_filtered\"\n```\n\n## Custom Jinja Tests\n\nCustom Jinja tests can be used by providing a set of Python classes where each test is implemented as a separate `Test` class in a `.py` file located in the `--tests` path. The class must have a single attribute named `name`, the test name, and a `classmethod()` named `test` which has one or more arguments. A sample test can be found below.\n\n```python\nclass Test:\n    name = \"test1\"\n\n    @classmethod\n    def test(cls, data1, data2):\n        return data1 == data2\n```\n\n## Rendering Directives\n\nSpecial rendering directives exist to render a single test suite per (YAML) list item. The directive can be added to the Robot template as a Jinja comment following this syntax:\n\n```\n{# iterate_list \u003cYAML_PATH_TO_LIST\u003e \u003cLIST_ITEM_ID\u003e \u003cJINJA_VARIABLE_NAME\u003e #}\n```\n\nAfter running `nac-test` with the data from the previous [example](#example) and the following template:\n\n```\n{# iterate_list root.children name child_name #}\n*** Settings ***\nDocumentation   Test1\n\n*** Test Cases ***\n{% for child in root.children | default([]) %}\n{% if child.name == child_name %}\n\nTest {{ child.name }}\n    Should Be Equal   {{ child.param }}   value\n{% endif %}\n{% endfor %}\n```\n\nThe following test suites will be rendered:\n\n```shell\n$ tree -L 2 tests\ntests\n├── ABC\n│   └── test1.robot\n└── DEF\n    └── test1.robot\n```\n\nA similar directive exists to put the test suites in a common folder though with a unique filename.\n\n```\n{# iterate_list_folder \u003cYAML_PATH_TO_LIST\u003e \u003cLIST_ITEM_ID\u003e \u003cJINJA_VARIABLE_NAME\u003e #}\n```\n\nThe following test suites will be rendered:\n\n```shell\n$ tree -L 2 tests\ntests\n└── test1\n    ├── ABC.robot\n    └── DEF.robot\n```\n\n## Select Test Cases By Tag\n\nIt is possible to include and exclude test cases by tag names with the `--include` and `--exclude` CLI options. These options are directly passed to the Pabot/Robot executor and are documented [here](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#by-tag-names).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetascode%2Fnac-test","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetascode%2Fnac-test","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetascode%2Fnac-test/lists"}