diff --git a/src/Mod/Test/CMakeLists.txt b/src/Mod/Test/CMakeLists.txt index 81d1422ed8..c2f8105c47 100644 --- a/src/Mod/Test/CMakeLists.txt +++ b/src/Mod/Test/CMakeLists.txt @@ -4,6 +4,7 @@ SET(Test_SRCS Init.py BaseTests.py Document.py + Metadata.py Menu.py TestApp.py TestGui.py @@ -14,7 +15,12 @@ SET(Test_SRCS testmakeWireString.py TestPythonSyntax.py ) -SOURCE_GROUP("" FILES ${Test_SRCS}) + +SET(TestData_SRCS + TestData/basic_metadata.xml +) + +SOURCE_GROUP("" FILES ${Test_SRCS} ${TestData_SRCS}) if(BUILD_GUI) add_subdirectory(Gui) @@ -22,14 +28,15 @@ if(BUILD_GUI) endif(BUILD_GUI) ADD_CUSTOM_TARGET(Test ALL - SOURCES ${Test_SRCS} + SOURCES ${Test_SRCS} ${TestData_SRCS} ) -fc_copy_sources(Test "${CMAKE_BINARY_DIR}/Mod/Test" ${Test_SRCS}) +fc_copy_sources(Test "${CMAKE_BINARY_DIR}/Mod/Test" ${Test_SRCS} ${TestData_SRCS}) INSTALL( FILES - ${Test_SRCS} + ${Test_SRCS} + ${TestData_SRCS} DESTINATION Mod/Test ) diff --git a/src/Mod/Test/Init.py b/src/Mod/Test/Init.py index f9d3759960..b9519da36d 100644 --- a/src/Mod/Test/Init.py +++ b/src/Mod/Test/Init.py @@ -27,5 +27,6 @@ FreeCAD.__unit_test__ += [ "BaseTests", "UnitTests", "Document", + "Metadata", "UnicodeTests", "TestPythonSyntax" ] diff --git a/src/Mod/Test/Metadata.py b/src/Mod/Test/Metadata.py new file mode 100644 index 0000000000..3a31c30ab3 --- /dev/null +++ b/src/Mod/Test/Metadata.py @@ -0,0 +1,74 @@ +# -*- coding: utf-8 -*- + +# *************************************************************************** +# * Copyright (c) 2022 FreeCAD Project Association * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This library is free software; you can redistribute it and/or * +# * modify it under the terms of the GNU Lesser General Public * +# * License as published by the Free Software Foundation; either * +# * version 2.1 of the License, or (at your option) any later version. * +# * * +# * This library is distributed in the hope that it will be useful, * +# * but WITHOUT ANY WARRANTY; without even the implied warranty of * +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * +# * Lesser General Public License for more details. * +# * * +# * You should have received a copy of the GNU Lesser General Public * +# * License along with this library; if not, write to the Free Software * +# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * +# * 02110-1301 USA * +# * * +# *************************************************************************** + +import FreeCAD +import unittest +import os + +class TestMetadata(unittest.TestCase): + + def setUp(self): + self.test_dir = os.path.join(FreeCAD.getHomePath(), "Mod", "Test", "TestData") + + def test_toplevel_tags(self): + filename = os.path.join(self.test_dir, "basic_metadata.xml") + md = FreeCAD.Metadata(filename) + + # Tags with only one element: + self.assertEqual(md.Name, "Test Workbench") + self.assertEqual(md.Description, "A package.xml file for unit testing.") + self.assertEqual(md.Version, "1.0.1") + #self.assertEqual(md.Date, "2022-01-07") + self.assertEqual(md.Icon, "Resources/icons/PackageIcon.svg") + + # Tags that are lists of elements: + maintainers = md.Maintainer + self.assertEqual(len(maintainers), 2) + + authors = md.Author + self.assertEqual(len(authors), 3) + + urls = md.Urls + self.assertEqual(len(urls), 4) + + tags = md.Tag + self.assertEqual(len(tags), 2) + + def test_content_types(self): + pass + + def test_content_item_tags(self): + pass + + def test_last_supported_version(self): + pass + + def test_first_supported_version(self): + pass + + def test_supports_current(self): + pass + + def test_generic_metadata(self): + pass \ No newline at end of file diff --git a/src/Mod/Test/TestData/basic_metadata.xml b/src/Mod/Test/TestData/basic_metadata.xml new file mode 100644 index 0000000000..a6f02cc5d2 --- /dev/null +++ b/src/Mod/Test/TestData/basic_metadata.xml @@ -0,0 +1,20 @@ + + + Test Workbench + A package.xml file for unit testing. + 1.0.1 + 2022-01-07 + FreeCAD Developer 1 + FreeCAD Developer 2 + FreeCAD Developer 3 + FreeCAD Developer 4 + FreeCAD Developer 5 + LGPLv2.1 + https://github.com/chennes/FreeCAD-Package + https://github.com/chennes/FreeCAD-Package/blob/main/README.md + https://github.com/chennes/FreeCAD-Package/blob/main/README.md + https://github.com/chennes/FreeCAD-Package/issues + Resources/icons/PackageIcon.svg + Tag0 + Tag1 + \ No newline at end of file