daitum-test 0.5.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,190 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ Copyright 2026 Daitum
179
+
180
+ Licensed under the Apache License, Version 2.0 (the "License");
181
+ you may not use this file except in compliance with the License.
182
+ You may obtain a copy of the License at
183
+
184
+ http://www.apache.org/licenses/LICENSE-2.0
185
+
186
+ Unless required by applicable law or agreed to in writing, software
187
+ distributed under the License is distributed on an "AS IS" BASIS,
188
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
189
+ implied. See the License for the specific language governing
190
+ permissions and limitations under the License.
@@ -0,0 +1,129 @@
1
+ Metadata-Version: 2.4
2
+ Name: daitum-test
3
+ Version: 0.5.2
4
+ Summary: Test Daitum models from Python
5
+ Author-email: Daitum <developers@daitum.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://daitum.com
8
+ Project-URL: Documentation, https://daitum-test.readthedocs.io
9
+ Project-URL: Repository, https://github.com/daitumapi/daitum-test
10
+ Project-URL: Issues, https://github.com/daitumapi/daitum-test/issues
11
+ Project-URL: Changelog, https://github.com/daitumapi/daitum-test/blob/main/CHANGELOG.md
12
+ Keywords: daitum,testing,optimisation,model,pytest
13
+ Classifier: Development Status :: 3 - Alpha
14
+ Classifier: Framework :: Pytest
15
+ Classifier: Intended Audience :: Developers
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Testing
22
+ Classifier: Typing :: Typed
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ Provides-Extra: dev
27
+ Requires-Dist: black==26.1.0; extra == "dev"
28
+ Requires-Dist: ruff==0.14.13; extra == "dev"
29
+ Requires-Dist: mypy==1.19.1; extra == "dev"
30
+ Requires-Dist: pytest; extra == "dev"
31
+ Requires-Dist: types-setuptools; extra == "dev"
32
+ Provides-Extra: docs
33
+ Requires-Dist: sphinx>=7.0; extra == "docs"
34
+ Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == "docs"
35
+ Requires-Dist: sphinx-rtd-theme>=3.0; extra == "docs"
36
+ Dynamic: license-file
37
+
38
+ # daitum-test
39
+
40
+ Test Daitum models from Python. Load a model, feed it data, run it, and make plain
41
+ assertions about the results — tables, named values, and diagnostics — without the platform.
42
+
43
+ ## What it's for
44
+
45
+ Write fast, local, repeatable tests for your models: unit-test a formula against crafted
46
+ inputs, check an optimisation stays within budget, assert an output table has no error cells,
47
+ or compare several scenarios in one run. It replaces slow platform round-trips and
48
+ hand-reimplemented formulas with assertions against what the model actually computes.
49
+
50
+ ```python
51
+ from daitum_test import Evaluator, Model, Run
52
+
53
+ model = Model.from_archive("MyModel.zip")
54
+ evaluator = Evaluator()
55
+
56
+ result = evaluator.evaluate(model, runs=[
57
+ Run(id="high-demand", scenario="Initial", mode="OPTIMISER",
58
+ tables={"Items": "fixtures/items_high_demand.csv"}, # cells typed from the model
59
+ named_values={"Budget": 50_000}),
60
+ ])
61
+
62
+ run = result["high-demand"]
63
+ assert run.errors == []
64
+ assert run.named_value("TotalCost") <= 50_000
65
+ assert run.table("Output").row_count >= 1
66
+ assert run.table("Output").error_cells() == []
67
+ ```
68
+
69
+ Load a model from an exported zip (`Model.from_archive`), a model directory
70
+ (`Model.from_directory`), or an in-process definition (`Model.from_definition` — daitum-core
71
+ builders work directly). Feed data as CSV files or inline rows; cells are typed automatically
72
+ from the model's own field definitions. A pytest plugin provides a ready-made `evaluator`
73
+ fixture. See the [cookbook](https://daitum-test.readthedocs.io/en/latest/cookbook.html) for the
74
+ patterns worth following — above all, batch a module's runs into a single `evaluate` call.
75
+
76
+ ## Installation
77
+
78
+ ```bash
79
+ pip install daitum-test
80
+ ```
81
+
82
+ The package has no runtime dependencies beyond the Python standard library.
83
+
84
+ ## Requirements
85
+
86
+ Evaluation runs against the Daitum model engine, which is distributed separately from this
87
+ package and requires access to obtain.
88
+
89
+ 1. Request access and download the engine (contact Daitum).
90
+ 2. Point the wrapper at it with the `EVALUATOR_JAR` environment variable.
91
+ 3. Have a supported Java runtime available (Java 25+). The wrapper finds it automatically, or
92
+ set `EVALUATOR_JAVA` / `JAVA_HOME` to choose one.
93
+
94
+ Tests that don't invoke the engine (building requests, converting data) need none of this; the
95
+ `integration`-marked tests do.
96
+
97
+ ## Development
98
+
99
+ ```bash
100
+ python -m venv venv
101
+ source venv/bin/activate
102
+ pip install -e ".[dev,docs]"
103
+
104
+ ./pipelines/lint.sh # Black + Ruff + MyPy
105
+ pytest # unit tests (integration tests are deselected by default)
106
+ ./pipelines/docs.sh # build the Sphinx docs
107
+ ```
108
+
109
+ Run the engine-backed tests explicitly once access is set up:
110
+
111
+ ```bash
112
+ pytest -m integration
113
+ ```
114
+
115
+ ## Documentation
116
+
117
+ Full reference and recipes: [daitum-test.readthedocs.io](https://daitum-test.readthedocs.io).
118
+
119
+ ## Support
120
+
121
+ Questions and bug reports: [github.com/daitumapi/daitum-test/issues](https://github.com/daitumapi/daitum-test/issues).
122
+
123
+ ## Changelog
124
+
125
+ See [CHANGELOG.md](CHANGELOG.md).
126
+
127
+ ## Licence
128
+
129
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,92 @@
1
+ # daitum-test
2
+
3
+ Test Daitum models from Python. Load a model, feed it data, run it, and make plain
4
+ assertions about the results — tables, named values, and diagnostics — without the platform.
5
+
6
+ ## What it's for
7
+
8
+ Write fast, local, repeatable tests for your models: unit-test a formula against crafted
9
+ inputs, check an optimisation stays within budget, assert an output table has no error cells,
10
+ or compare several scenarios in one run. It replaces slow platform round-trips and
11
+ hand-reimplemented formulas with assertions against what the model actually computes.
12
+
13
+ ```python
14
+ from daitum_test import Evaluator, Model, Run
15
+
16
+ model = Model.from_archive("MyModel.zip")
17
+ evaluator = Evaluator()
18
+
19
+ result = evaluator.evaluate(model, runs=[
20
+ Run(id="high-demand", scenario="Initial", mode="OPTIMISER",
21
+ tables={"Items": "fixtures/items_high_demand.csv"}, # cells typed from the model
22
+ named_values={"Budget": 50_000}),
23
+ ])
24
+
25
+ run = result["high-demand"]
26
+ assert run.errors == []
27
+ assert run.named_value("TotalCost") <= 50_000
28
+ assert run.table("Output").row_count >= 1
29
+ assert run.table("Output").error_cells() == []
30
+ ```
31
+
32
+ Load a model from an exported zip (`Model.from_archive`), a model directory
33
+ (`Model.from_directory`), or an in-process definition (`Model.from_definition` — daitum-core
34
+ builders work directly). Feed data as CSV files or inline rows; cells are typed automatically
35
+ from the model's own field definitions. A pytest plugin provides a ready-made `evaluator`
36
+ fixture. See the [cookbook](https://daitum-test.readthedocs.io/en/latest/cookbook.html) for the
37
+ patterns worth following — above all, batch a module's runs into a single `evaluate` call.
38
+
39
+ ## Installation
40
+
41
+ ```bash
42
+ pip install daitum-test
43
+ ```
44
+
45
+ The package has no runtime dependencies beyond the Python standard library.
46
+
47
+ ## Requirements
48
+
49
+ Evaluation runs against the Daitum model engine, which is distributed separately from this
50
+ package and requires access to obtain.
51
+
52
+ 1. Request access and download the engine (contact Daitum).
53
+ 2. Point the wrapper at it with the `EVALUATOR_JAR` environment variable.
54
+ 3. Have a supported Java runtime available (Java 25+). The wrapper finds it automatically, or
55
+ set `EVALUATOR_JAVA` / `JAVA_HOME` to choose one.
56
+
57
+ Tests that don't invoke the engine (building requests, converting data) need none of this; the
58
+ `integration`-marked tests do.
59
+
60
+ ## Development
61
+
62
+ ```bash
63
+ python -m venv venv
64
+ source venv/bin/activate
65
+ pip install -e ".[dev,docs]"
66
+
67
+ ./pipelines/lint.sh # Black + Ruff + MyPy
68
+ pytest # unit tests (integration tests are deselected by default)
69
+ ./pipelines/docs.sh # build the Sphinx docs
70
+ ```
71
+
72
+ Run the engine-backed tests explicitly once access is set up:
73
+
74
+ ```bash
75
+ pytest -m integration
76
+ ```
77
+
78
+ ## Documentation
79
+
80
+ Full reference and recipes: [daitum-test.readthedocs.io](https://daitum-test.readthedocs.io).
81
+
82
+ ## Support
83
+
84
+ Questions and bug reports: [github.com/daitumapi/daitum-test/issues](https://github.com/daitumapi/daitum-test/issues).
85
+
86
+ ## Changelog
87
+
88
+ See [CHANGELOG.md](CHANGELOG.md).
89
+
90
+ ## Licence
91
+
92
+ Apache 2.0 — see [LICENSE](LICENSE).
@@ -0,0 +1,141 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "daitum-test"
7
+ version = "0.5.2"
8
+ description = "Test Daitum models from Python"
9
+ readme = "README.md"
10
+ license = "Apache-2.0"
11
+ authors = [{ name = "Daitum", email = "developers@daitum.com" }]
12
+ requires-python = ">=3.10"
13
+ keywords = ["daitum", "testing", "optimisation", "model", "pytest"]
14
+ classifiers = [
15
+ "Development Status :: 3 - Alpha",
16
+ "Framework :: Pytest",
17
+ "Intended Audience :: Developers",
18
+ "Operating System :: OS Independent",
19
+ "Programming Language :: Python :: 3.10",
20
+ "Programming Language :: Python :: 3.11",
21
+ "Programming Language :: Python :: 3.12",
22
+ "Programming Language :: Python :: 3.13",
23
+ "Topic :: Software Development :: Testing",
24
+ "Typing :: Typed",
25
+ ]
26
+ # The package drives the model engine over a subprocess, so it needs nothing beyond the
27
+ # standard library at runtime.
28
+ dependencies = []
29
+
30
+ [project.entry-points.pytest11]
31
+ daitum_test = "daitum_test.plugin"
32
+
33
+ [project.urls]
34
+ Homepage = "https://daitum.com"
35
+ Documentation = "https://daitum-test.readthedocs.io"
36
+ Repository = "https://github.com/daitumapi/daitum-test"
37
+ Issues = "https://github.com/daitumapi/daitum-test/issues"
38
+ Changelog = "https://github.com/daitumapi/daitum-test/blob/main/CHANGELOG.md"
39
+
40
+ [project.optional-dependencies]
41
+ dev = [
42
+ "black==26.1.0",
43
+ "ruff==0.14.13",
44
+ "mypy==1.19.1",
45
+ "pytest",
46
+ "types-setuptools",
47
+ ]
48
+ docs = [
49
+ "sphinx>=7.0",
50
+ "sphinx-autodoc-typehints>=1.25",
51
+ "sphinx-rtd-theme>=3.0",
52
+ ]
53
+
54
+ [tool.setuptools.packages.find]
55
+ where = ["src"]
56
+
57
+ [tool.setuptools.package-data]
58
+ "daitum_test" = ["py.typed"]
59
+
60
+ # -----------------------------
61
+ # Ruff formatting + linting
62
+ # -----------------------------
63
+ [tool.ruff]
64
+ line-length = 100
65
+ target-version = "py310"
66
+ fix = true
67
+ extend-exclude = ["tests"]
68
+ # Apply the exclusion even when lint.sh passes tests/ explicitly.
69
+ force-exclude = true
70
+
71
+ [tool.ruff.lint]
72
+ # E = Pycodestyle errors (syntax/whitespace)
73
+ # F = Pyflakes checks (undefined names, unused imports)
74
+ # B = Bugbear rules (common mistakes / best practices)
75
+ # UP = Pyupgrade (modern syntax)
76
+ # I = Import sorting (isort-like)
77
+ # N = Naming conventions
78
+ # PL = PyLint rules
79
+ # TID = Import tidiness rules
80
+ select = ["E", "F", "B", "UP", "I", "N", "PL", "TID"]
81
+ ignore = [
82
+ # PLR0402 conflicts with the architecture rule requiring 'import X.Y as Y' for aliases.
83
+ "PLR0402",
84
+ ]
85
+
86
+ [tool.ruff.lint.isort]
87
+ known-first-party = ["daitum_test"]
88
+ combine-as-imports = true
89
+
90
+ # -----------------------------
91
+ # Black (formatting)
92
+ # -----------------------------
93
+ [tool.black]
94
+ line-length = 100
95
+ target-version = ['py310']
96
+ include = '\.pyi?$'
97
+ exclude = '''
98
+ /(
99
+ .git
100
+ | venv
101
+ | .venv
102
+ | model
103
+ | dist
104
+ | build
105
+ | __pycache__
106
+ | .mypy_cache
107
+ | .ruff_cache
108
+ | .idea
109
+ )/
110
+ '''
111
+
112
+ # -----------------------------
113
+ # Mypy config
114
+ # -----------------------------
115
+ [tool.mypy]
116
+ python_version = "3.10"
117
+ # src-layout: treat src/ as the import root so modules resolve as daitum_test.* only.
118
+ mypy_path = "src"
119
+ explicit_package_bases = true
120
+ warn_return_any = true
121
+ warn_unused_configs = true
122
+ check_untyped_defs = true
123
+ exclude = [
124
+ "venv",
125
+ ".venv",
126
+ "model",
127
+ "__pycache__",
128
+ ".mypy_cache",
129
+ ".ruff_cache",
130
+ ".idea",
131
+ "tests",
132
+ ]
133
+
134
+ [tool.pytest.ini_options]
135
+ testpaths = ["tests"]
136
+ # Integration tests invoke the real evaluator jar and need EVALUATOR_JAR set; skip by default.
137
+ # Run them explicitly with: pytest -m integration
138
+ addopts = "-m 'not integration' --strict-markers"
139
+ markers = [
140
+ "integration: tests that invoke the real evaluator jar (deselected by default in CI).",
141
+ ]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,107 @@
1
+ # Copyright 2026 Daitum
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ """
16
+ daitum_test - Test Daitum models from Python
17
+ ============================================
18
+
19
+ Load a model, feed it data, run it, and make plain assertions about the results — tables,
20
+ named values, and diagnostics — locally, without the platform. Use it to unit-test a formula
21
+ against crafted inputs, check an optimisation result, assert an output table has no error
22
+ cells, or compare several scenarios in one run.
23
+
24
+ .. code-block:: python
25
+
26
+ from daitum_test import Evaluator, Model, Run
27
+
28
+ model = Model.from_archive("MyModel.zip")
29
+ evaluator = Evaluator()
30
+
31
+ result = evaluator.evaluate(model, runs=[
32
+ Run(scenario="Initial", id="high-demand", mode="OPTIMISER",
33
+ tables={"Items": "fixtures/items_high_demand.csv"},
34
+ named_values={"Budget": 50_000}),
35
+ ])
36
+
37
+ run = result["high-demand"]
38
+ assert run.errors == []
39
+ assert run.named_value("TotalCost") <= 50_000
40
+ assert run.table("Output").row_count >= 1
41
+ assert run.table("Output").error_cells() == []
42
+
43
+ Load a model with :meth:`Model.from_archive`, :meth:`Model.from_directory`, or
44
+ :meth:`Model.from_definition` (daitum-core builders work directly). Feed data as CSV files or
45
+ inline rows — cells are typed from the model's own field definitions. A pytest plugin provides
46
+ a ready-made ``evaluator`` fixture.
47
+
48
+ Install with ``pip install daitum-test`` (no runtime dependencies beyond the standard
49
+ library). Evaluation runs against the Daitum model engine, which is obtained separately and
50
+ located via the ``EVALUATOR_JAR`` environment variable, with a Java 25+ runtime available; see
51
+ the README. Each evaluation loads the whole model once, so batch a module's runs into a single
52
+ ``evaluate`` call (e.g. from a module-scoped fixture) rather than calling per test.
53
+ """
54
+
55
+ from daitum_test.data import ERROR, INDEX_KEY, REF_KEY
56
+ from daitum_test.errors import (
57
+ ContractError,
58
+ DaitumTestError,
59
+ DataConversionError,
60
+ EvaluatorCrashError,
61
+ EvaluatorNotFoundError,
62
+ ModelInspectionError,
63
+ UnknownFieldError,
64
+ UnknownNamedValueError,
65
+ UnknownRunError,
66
+ UnknownTableError,
67
+ )
68
+ from daitum_test.evaluator import Evaluator
69
+ from daitum_test.model import Model
70
+ from daitum_test.result import (
71
+ Diagnostic,
72
+ ErrorCell,
73
+ EvaluationResult,
74
+ RunResult,
75
+ TableResult,
76
+ ValidationReport,
77
+ is_error_cell,
78
+ )
79
+ from daitum_test.run import Options, Run, TableLike
80
+
81
+ __all__ = [
82
+ "ERROR",
83
+ "INDEX_KEY",
84
+ "REF_KEY",
85
+ "ContractError",
86
+ "DaitumTestError",
87
+ "DataConversionError",
88
+ "Diagnostic",
89
+ "ErrorCell",
90
+ "EvaluationResult",
91
+ "Evaluator",
92
+ "EvaluatorCrashError",
93
+ "EvaluatorNotFoundError",
94
+ "Model",
95
+ "ModelInspectionError",
96
+ "Options",
97
+ "Run",
98
+ "RunResult",
99
+ "TableLike",
100
+ "TableResult",
101
+ "UnknownFieldError",
102
+ "UnknownNamedValueError",
103
+ "UnknownRunError",
104
+ "UnknownTableError",
105
+ "ValidationReport",
106
+ "is_error_cell",
107
+ ]