unit_tests
These are utilities for working with CaC/content unit tests, as built by the CaC/content built system.
To satisfy various use cases, the logic is modularized into functions:
iter_rules() iterates over all built tests, yielding rules
iter_tests() iterates over .sh tests for one rule, yielding partial UnitTest with info from the rule directory (rule, test, is_pass)
fill_in_metadata() reads the .sh contents and completes UnitTest based on metadata contained in the .sh file
Module Contents
- class unit_tests.UnitTest
Bases:
tuple
- rule
- test
- is_pass
- packages
- profiles
- variables
- remediation
- check
- unit_tests.parse_variables(line)
- unit_tests.fill_in_metadata(unit_test, test_file)
Given an (incomplete) UnitTest tuple as ‘unit_test’, fill in values from unit test file metadata, returning the complete UnitTest.
- unit_tests.iter_tests(rule_dir)
Given a rule directory containing tests, yield tuples of (partial UnitTest , test file path) representing tests found in that directory.
- unit_tests.iter_rules(built_tests_dir)
Given a directory with built tests, yield pathlib.Path directories with tests, the names of which should correspond to rule names, plus the special directory ‘shared’.