From 4999209f9ce01c824020f5b68403c5b4b52d3e8c Mon Sep 17 00:00:00 2001 From: jvoisin Date: Sat, 13 Jul 2019 21:26:05 +0200 Subject: Add support for svg --- tests/data/dirty.svg | 636 +++++++++++++++++++++++++++++++++++++++++++++++ tests/data/embedded.docx | Bin 24601 -> 24316 bytes tests/data/embedded.odt | Bin 33019 -> 32651 bytes tests/test_libmat2.py | 28 ++- 4 files changed, 662 insertions(+), 2 deletions(-) create mode 100644 tests/data/dirty.svg (limited to 'tests') diff --git a/tests/data/dirty.svg b/tests/data/dirty.svg new file mode 100644 index 0000000..e2bde85 --- /dev/null +++ b/tests/data/dirty.svg @@ -0,0 +1,636 @@ + + + + + + Adwaita Icon Template + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + GNOME Design Team + + + mat2's source code + + Adwaita Icon Template + + + mat2 + logo + metadata + + + 2019 07 13 + + + LGPL + + + + + jvoisin + + + mat2-testdata-svg + + English + + This is a test svg image for mat2's testsuite + + + jvoisin, and Rose for the design + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/data/embedded.docx b/tests/data/embedded.docx index b134724..615e522 100644 Binary files a/tests/data/embedded.docx and b/tests/data/embedded.docx differ diff --git a/tests/data/embedded.odt b/tests/data/embedded.odt index 62bf8cc..c5fffc8 100644 Binary files a/tests/data/embedded.odt and b/tests/data/embedded.odt differ diff --git a/tests/test_libmat2.py b/tests/test_libmat2.py index 64e679f..796d2f1 100644 --- a/tests/test_libmat2.py +++ b/tests/test_libmat2.py @@ -73,13 +73,13 @@ class TestParameterInjection(unittest.TestCase): class TestUnsupportedEmbeddedFiles(unittest.TestCase): - def test_odt_with_svg(self): + def test_odt_with_py(self): shutil.copy('./tests/data/embedded.odt', './tests/data/clean.odt') p = office.LibreOfficeParser('./tests/data/clean.odt') self.assertFalse(p.remove_all()) os.remove('./tests/data/clean.odt') - def test_docx_with_svg(self): + def test_docx_with_py(self): shutil.copy('./tests/data/embedded.docx', './tests/data/clean.docx') p = office.MSOfficeParser('./tests/data/clean.docx') self.assertFalse(p.remove_all()) @@ -862,3 +862,27 @@ class TestCleaning(unittest.TestCase): os.remove('./tests/data/dirty.tar.xz') os.remove('./tests/data/dirty.cleaned.tar.xz') os.remove('./tests/data/dirty.cleaned.cleaned.tar.xz') + + def test_svg(self): + shutil.copy('./tests/data/dirty.svg', './tests/data/clean.svg') + p = images.SVGParser('./tests/data/clean.svg') + + meta = p.get_meta() + self.assertEqual(meta['WorkCreatorAgentTitle'], 'GNOME Design Team') + self.assertEqual(meta['WorkSubject'], ['mat2', 'logo', 'metadata']) + self.assertEqual(meta['ID'], 'svg11300') + self.assertEqual(meta['Output_extension'], + 'org.inkscape.output.svg.inkscape') + + ret = p.remove_all() + self.assertTrue(ret) + + p = images.SVGParser('./tests/data/clean.cleaned.svg') + self.assertEqual(p.get_meta(), {}) + self.assertTrue(p.remove_all()) + + os.remove('./tests/data/clean.svg') + os.remove('./tests/data/clean.cleaned.svg') + os.remove('./tests/data/clean.cleaned.cleaned.svg') + + -- cgit v1.3