Skip to content

feat: update JUnit and Python unit tests to have same coverage as Rune-DSL - #254

Open
dschwartznyc wants to merge 1 commit into
mainfrom
feat-increase-testing-coverage
Open

feat: update JUnit and Python unit tests to have same coverage as Rune-DSL#254
dschwartznyc wants to merge 1 commit into
mainfrom
feat-increase-testing-coverage

Conversation

@dschwartznyc

Copy link
Copy Markdown
Contributor

Overview

Increases JUnit and Python unit test coverage in the Python generator to mirror the test suite in rune-dsl. The branch adds dedicated test classes for expression categories that previously lacked explicit coverage, extends existing collection expression tests, and introduces a parallel set of Python unit tests that exercise the same features end-to-end through the generator and runtime.


New JUnit Test Classes

Class Tests Coverage area
PythonCountOperationTest 6 count lambda generation in function bodies, list literals, conditions, and field comparisons
PythonDeepPathTest 4 Deep path (->>) operator generation in conditions, feature calls, and inheritance hierarchies
PythonEmptyEvaluationTest 6 absent / exists evaluation, optional attribute defaults, None fallback in conditional expressions
PythonObjectExpressionTest 6 Constructor expressions including ellipsis (...) syntax and list-literal initialisation
PythonTypeAliasConditionTest 4 + 1 disabled Type alias reduction to Python primitives; one @Disabled test documents the known gap that conditions on typeAlias definitions are not generated

Extended JUnit Test Classes

  • PythonCollectionExpressionTest — added testSortWithKeyExpression covering sorted(..., key=lambda item: rune_resolve_attr(...)) generation for sort operations with an explicit key attribute

New Python Unit Tests

Each entry is a Rune model paired with a pytest file that exercises generated code end-to-end.

Rosetta model Test file What it covers
Constructor.rosetta test_constructor.py Full and partial constructor expressions; nested list-of-objects constructor
EmptyEvaluation.rosetta test_empty_evaluation.py IsAbsent / IsPresent functions on optional boolean fields; all four absent/present combinations
TypeAliasCondition.rosetta test_type_alias_condition.py Documents that type alias conditions are not enforced at runtime; INVALID values are accepted without error (known gap)

Extended Python Unit Tests

  • SortClosure.rosetta / test_sort_closure.py — added SortItemsBySecondField (sort by a second attribute), SortIntegers (plain sort without a key), and assertions that all non-null items are preserved after sorting

Known Gap Documented

typeAlias conditions are not generated in Python. The generator strips all type aliases to their underlying primitive (str, int, etc.) and discards any condition block on the alias. This affects codelist validation (FpMLCodingScheme and its derivatives) and is tracked separately. The gap is documented in PythonTypeAliasConditionTest (@Disabled) and test_type_alias_condition.py.

@dschwartznyc dschwartznyc added the enhancement New feature or request label Jul 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants