Test for various SAP Commissions ODI file templates.
-
Clone the repository to your local machine:
git clone https://github.com/niro1987/sapcommissions-pytests
-
Install requirements:
python -m pip install -r requirements.txt
-
Place your ODI files in the
source
directory. -
Run tests.
python -m pytest
A detailed report is generated at ./report.html
.
The repository is configured to work with VSCode. Open Test Explorer using the icon
on the Activity Bar. Running tests this way will not generate an html report.
I encourage anyone to write additional tests for their respective ODI templates. Fork the repository to make your changes and open a pull request to get your changes merged.
Each test files should include a pytest marker to exlude the entire module if no files for the specific template are found in the source folder.
from .common import source_files
pytestmark = pytest.mark.skipif(
len(source_files('TEMPLATE')) == 0,
reason=f"No files found for this ODI template."
)
Inherrit from common.GenericTests
to include tests that any ODI template should pass.
GenericTests
expects some class variables to be included, see example below.
from .common import GenericTests
class TestMyTemplate(GenericTests)
"""Tests for MyTemplate."""
template: str = "MY_TEMPLATE"
primary_key: list[str] = [] # Columns that make the row unique in the file.
required: list[str] = [] # Columns that are required to be filled.
numbers: list[str] = [] # Number columns, joined by UNITTYPEFOR... columns.
dates: list[str] = [] # Date columns, MM/DD/YYYY format.
booleans: list[str] = [] # Boolean columns, can only contain NULL, 0 or 1.