You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/how-tos/using-pynxtools-test-framework.md
+83-3Lines changed: 83 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,9 +7,7 @@ To test integration of a plugin with the `pynxtools` core system, we need to:
7
7
## How to write an integration test for a reader plugin with `pynxtools.testing`
8
8
It is very simple to write a test to verify the plugin integration with `pynxtools` within the plugin's tests directory. The developer can place the test where they want, but they need to use the provided test interface from `pynxtools`. An example test for `pynxtools-FOO` (a demo plugin) plugin is given below:
# Use `ignore_undocumented` to skip undocumented fields
52
50
# caplog_level can be "ERROR" or "WARNING"
53
51
test.check_reproducibility_of_nexus()
52
+
# Here, you can also pass `ignore_lines` (a list) or `ignore_sections` (a dict)
53
+
# if you want to ignore certain lines or lines within a section in the comparison
54
+
# of the log files of the reference -nxs file and the one created in the test.
54
55
```
55
56
56
57
Alongside the test data in `test/data`, it is also possible to add other types of test data inside the test directory of the plugin.
@@ -60,3 +61,82 @@ You can also pass additional parameters to `test.convert_to_nexus`:
60
61
-`caplog_level` (str): Can be either "ERROR" (by default) or "warning". This parameter determines the level at which the caplog is set during testing. If it is "WARNING", the test will also fail if any warnings are reported by the reader.
61
62
62
63
-`ignore_undocumented` (boolean): If true, the test skipts the verification of undocumented keys. Otherwise, a warning massages for undocumented keys is raised
64
+
65
+
# How to write an integration test for a NOMAD example in a reader plugin
66
+
It is also possible to ship examples for NOMAD directly with the reader plugin. As an example, `pynxtools-mpes` comes with its own NOMAD example (see [here](https://github.com/FAIRmat-NFDI/pynxtools-mpes/tree/bring-in-examples/src/pynxtools_mpes/nomad)) using the ExampleUploadEntryPoint of NOMAD (see [here](https://nomad-lab.eu/prod/v1/staging/docs/howto/plugins/example_uploads.html) for more documentation).
67
+
68
+
The `testing` sub-package of `pynxtools` provides two functionalities for testing the `ExampleUploadEntryPoint` defined in a `pynxtools` plugin:
69
+
1) Test that the ExampleUploadEntryPoint can be properly loaded
70
+
2) Test that the schemas and files in the example folder(s) can be parsed by NOMAD
71
+
72
+
We will write a test for a `pynxtools_foo_example_entrypoint` defined in the pyproject.toml file of a demo `pynxtools-FOO` (here the actual example data resides in the folder `src/pynxtools_foo/nomad/examples`):
"Could not import nomad package. Please install the package 'nomad-lab'."
@@ -43,3 +64,14 @@ def load(self):
43
64
mainfile_name_re=r".*\.nxs",
44
65
mainfile_mime_re="application/x-hdf5",
45
66
)
67
+
68
+
iv_temp_example=ExampleUploadEntryPoint(
69
+
title="Sensor Scan - IV Temperature Curve",
70
+
category="FAIRmat examples",
71
+
description="""
72
+
This example shows users how to take data from a Python framework and map it out to a Nexus application definition for IV Temperature measurements, [`NXiv_temp`](https://fairmat-nfdi.github.io/nexus_definitions/classes/contributed_definitions/NXiv_temp.html).
73
+
We use the Nexus ELN features of NOMAD to generate a Nexus file.
0 commit comments