Skip to content

Commit 273a0a1

Browse files
a small typo and modify doc with new parameter caplog. (#342)
1 parent 791ab03 commit 273a0a1

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

docs/how-tos/using-pynxtools-test-framework.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# Generalized Test Functionality for `pynxtools` plugins
22
The `pynxtools` sub-package `testing` is to be utilized to write automated tests for pynxtools reader plugins without requiring in-depth knowledge of the pynxtools internal architecture. The tool supports generalised a general test for all reader plugins, irrespective of the technical details of the raw data files and the internal design of the plugin (note: it is assumed that the plugin was built from the [plugin template](https://github.com/FAIRmat-NFDI/pynxtools-plugin-template) or has the same structure internally).
33
## Why it is needed
4-
To test integration of a plugin with the `pynxtools` core system, we need to:
5-
1. Test the plugin's integration with `pynxtools` from the plugin's CI/CD.
4+
To test integration of a plugin with the `pynxtools` core system, we need to:
5+
1. Test the plugin's integration with `pynxtools` from the plugin's CI/CD.
66
2. Test in the pynxtools's CI/CD if the plugin has been integrated with `pynxtools` properly.
77
## How to write an integration test for a reader plugin with `pynxtools.testing`
88
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:
@@ -22,8 +22,8 @@ module_dir = os.path.dirname(os.path.abspath(__file__))
2222
@pytest.mark.parametrize(
2323
"nxdl,reader_name,files_or_dir",
2424
[
25-
("NXfoo", "foo", f"{module_dir}/../test/data/test_data_dir_1"),
26-
("NXfoo", "foo", f"{module_dir}/../test/data/test_data_dir_2")
25+
("NXfoo", "foo", f"{module_dir}/../tests/data/test_data_dir_1"),
26+
("NXfoo", "foo", f"{module_dir}/../tests/data/test_data_dir_2")
2727
],
2828
)
2929
def test_foo_reader(nxdl, reader_name, files_or_dir, tmp_path, caplog):
@@ -47,15 +47,16 @@ def test_foo_reader(nxdl, reader_name, files_or_dir, tmp_path, caplog):
4747
# test plugin reader
4848
test = ReaderTest(nxdl, reader_name, files_or_dir, tmp_path, caplog)
4949
test.convert_to_nexus()
50+
# test.convert_to_nexus(caplog_level="ERROR", ignore_undocumented=True)
5051
# Use `ignore_undocumented` to skip undocumented fields
51-
# test.convert_to_nexus(ignore_undocumented=True)
52+
# caplog_level can be "ERROR" or "WARNING"
5253
test.check_reproducibility_of_nexus()
5354
```
5455

5556
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.
5657

5758
You can also pass additional parameters to `test.convert_to_nexus`:
5859

59-
- `log_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.
60+
- `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.
6061

6162
- `ignore_undocumented` (boolean): If true, the test skipts the verification of undocumented keys. Otherwise, a warning massages for undocumented keys is raised

0 commit comments

Comments
 (0)