Get Help

CLI, PowerShell and Python side by side

CAT CLI, the PowerShell module and the Python module do the same things. This page puts each step in all three next to each other, for anyone who has an example in one tool and works in another.

Every command links its reference page, which has all the options. CAT Studio is not on this page: it has no commands.

The steps

Step CAT CLI PowerShell module Python module
Open the project every verb opens it: -p <path>, default the current directory Open-CatProject [-Path <path>] cat.open_project("<path>"), the path is required
Look at the project catcli show --summary Show-CatProject the Project object open_project returns: DataSources, Tests, Queries, Outputs
List the tests catcli show --tests [-f "<pattern>"] Get-CatTest cat.get_tests()
Run one query through a data source catcli exec -d <data source> -c "<query>" Invoke-CatCommand <data source> "<query>" cat.invoke_command("<data source>", "<query>")
Run all tests catcli run Invoke-CatTest cat.invoke_tests()
Run tests by name catcli run -f "<pattern>" Invoke-CatTest -Filter "<pattern>" cat.invoke_tests(filter="<pattern>")
Run tests by tags catcli run -i "a, b" -e c Invoke-CatTest -IncludeTag a, b -ExcludeTag c cat.invoke_tests(include_tags="a, b", exclude_tags="c")
Run without writing the outputs catcli run -n Invoke-CatTest -SkipOutputs cat.invoke_tests(skip_outputs=True)
Open and run in one call catcli run Invoke-CatProject cat.invoke_project("<path>")
Did every test pass? the exit code: 0 yes, 10 no Get-CatTestResultSummary: FailedCount, ErrorCount, InconclusiveCount cat.get_test_results_summary(): the same counts
Why did a test not pass? catcli run -l Error prints the message, or read the outputs Get-CatTestResult: TestResult, Message cat.get_test_results(): TestResult, Message

The filters work the same in all three: a name pattern takes * for any text and ? for one character, names and tags are not case-sensitive, and the filters combine.

What differs

One call or one session. Each catcli command opens the project again and ends. The modules open it once; the calls after Open-CatProject or cat.open_project work on that open project, until the next open.

The verdict. CAT CLI ends with an exit code. In the modules, a failed test is not an error: Invoke-CatTest and cat.invoke_tests return normally whatever the results, and the script reads the summary. Look at ErrorCount and InconclusiveCount as well as FailedCount: the exit code 10 counts all three.

The results as objects. The modules hand back every test’s result, so a script can carry on with it. For example, do something for every failed test with the tag Finance:

Open-CatProject
$s = Invoke-CatTest
$s.Results | Where-Object { $_.TestResult -eq 'Failed' -and $_.TestDefinition.Tags -contains 'Finance' } |
    ForEach-Object { "$($_.TestFullName): $($_.Message)" }
from justcatit import cat
cat.open_project("D:/Testing/DwhTests.cat.yaml")
s = cat.invoke_tests()
for r in s.Results:
    if str(r.TestResult) == "Failed" and "Finance" in list(r.TestDefinition.Tags):
        print(r.TestFullName, r.Message)

CAT CLI gives the same results as a file: a JSON output a script reads after the run.