Test: Add first tests for Metadata
This commit is contained in:
@@ -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
|
||||
)
|
||||
|
||||
@@ -27,5 +27,6 @@
|
||||
FreeCAD.__unit_test__ += [ "BaseTests",
|
||||
"UnitTests",
|
||||
"Document",
|
||||
"Metadata",
|
||||
"UnicodeTests",
|
||||
"TestPythonSyntax" ]
|
||||
|
||||
74
src/Mod/Test/Metadata.py
Normal file
74
src/Mod/Test/Metadata.py
Normal file
@@ -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
|
||||
20
src/Mod/Test/TestData/basic_metadata.xml
Normal file
20
src/Mod/Test/TestData/basic_metadata.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no" ?>
|
||||
<package format="1" xmlns="https://wiki.freecad.org/Package_Metadata">
|
||||
<name>Test Workbench</name>
|
||||
<description>A package.xml file for unit testing.</description>
|
||||
<version>1.0.1</version>
|
||||
<date>2022-01-07</date>
|
||||
<maintainer email="developer1@freecad.org">FreeCAD Developer 1</maintainer>
|
||||
<maintainer email="developer2@freecad.org">FreeCAD Developer 2</maintainer>
|
||||
<author email="developer3@freecad.org">FreeCAD Developer 3</author>
|
||||
<author>FreeCAD Developer 4</author>
|
||||
<author>FreeCAD Developer 5</author>
|
||||
<license file="LICENSE">LGPLv2.1</license>
|
||||
<url type="repository" branch="main">https://github.com/chennes/FreeCAD-Package</url>
|
||||
<url type="readme">https://github.com/chennes/FreeCAD-Package/blob/main/README.md</url>
|
||||
<url type="documentation">https://github.com/chennes/FreeCAD-Package/blob/main/README.md</url>
|
||||
<url type="bugtracker">https://github.com/chennes/FreeCAD-Package/issues</url>
|
||||
<icon>Resources/icons/PackageIcon.svg</icon>
|
||||
<tag>Tag0</tag>
|
||||
<tag>Tag1</tag>
|
||||
</package>
|
||||
Reference in New Issue
Block a user