From 66595e57881df0097a7d3fc75fdd6c77c54c4c3d Mon Sep 17 00:00:00 2001 From: Alexander Schlemmer <a.schlemmer@indiscale.com> Date: Fri, 17 Jan 2025 16:02:15 +0100 Subject: [PATCH] TST: deactivated zip file test for outdated eln and added simple zip test --- unittests/test_zipfile_converter.py | 32 ++++++++++++++++++++++++++++ unittests/zip_minimal/empty.zip | Bin 0 -> 536 bytes 2 files changed, 32 insertions(+) create mode 100644 unittests/zip_minimal/empty.zip diff --git a/unittests/test_zipfile_converter.py b/unittests/test_zipfile_converter.py index 9bc8b880..22e4f2ea 100644 --- a/unittests/test_zipfile_converter.py +++ b/unittests/test_zipfile_converter.py @@ -50,6 +50,12 @@ def converter_registry(): return converter_registry +@pytest.mark.xfail( + reason="The example files for PASTA have not yet been updated in:" + "https://github.com/TheELNConsortium/TheELNFileFormat/tree/master/examples/PASTA" + "However, there was the announcement that these files are going to follow the" + "flattened structure soon: https://github.com/TheELNConsortium/TheELNFileFormat/issues/98" +) def test_zipfile_converter(converter_registry): zipfile = File("PASTA.eln", os.path.join(UNITTESTDIR, "eln_files", "PASTA.eln")) zip_conv = ZipFileConverter(yaml.safe_load(""" @@ -77,3 +83,29 @@ match: ^PASTA$ assert isinstance(children[i], Directory) for i in range(2, 5): assert isinstance(children[i], File) + + +def test_zipfile_minimal(converter_registry): + zipfile = File("empty.zip", os.path.join(UNITTESTDIR, "zip_minimal", "empty.zip")) + zip_conv = ZipFileConverter(yaml.safe_load(""" +type: ZipFile +match: .*$ +"""), "TestZipFileConverter", converter_registry) + + match = zip_conv.match(zipfile) + assert match is not None + + children = zip_conv.create_children(GeneralStore(), zipfile) + assert len(children) == 2 + assert children[1].name == "empty.txt" + + dir_conv = DirectoryConverter(yaml.safe_load(""" +type: Directory +match: ^folder$ +"""), "TestDirectory", converter_registry) + match = dir_conv.match(children[0]) + assert match is not None + children = dir_conv.create_children(GeneralStore(), children[0]) + assert len(children) == 3 + for i in range(3): + assert isinstance(children[i], File) diff --git a/unittests/zip_minimal/empty.zip b/unittests/zip_minimal/empty.zip new file mode 100644 index 0000000000000000000000000000000000000000..3eb2cee755e1b0265b13b1ee8f31c2aa1abe62de GIT binary patch literal 536 zcmWIWW@Zs#00I66!zd69!|V(U3~Bi}DXB&J2u0jziUbjg(lT>W<CFDDDoPN_ISD9F zLRHQ|KzSmna_4$f7jrT&Fr?-dlvF~LF*4aR<MtZNn{ORKEVxGzny`5lq!fggG^%3v zI6^x%uY<IL@RG(5H0{uUKxoGn6d<i2yri)iO*=GT5ZbW?4M-~pFKOI_8c?ikAYoPp ORt8N*28Np;4g&y1#8I#S literal 0 HcmV?d00001 -- GitLab