Add root information to project file

This commit is contained in:
Veronica Berglyd Olsen
2022-04-02 19:43:26 +02:00
parent f9ddcd2f8a
commit 37970bd446
14 changed files with 207 additions and 166 deletions
+24 -5
View File
@@ -65,6 +65,18 @@ def testCoreItem_Setters(mockGUI):
theItem.setParent("0123456789abc")
assert theItem.itemParent == "0123456789abc"
# Root
theItem.setRoot(None)
assert theItem.itemRoot is None
theItem.setRoot(123)
assert theItem.itemRoot is None
theItem.setRoot("0123456789abcdef")
assert theItem.itemRoot is None
theItem.setRoot("0123456789abg")
assert theItem.itemRoot is None
theItem.setRoot("0123456789abc")
assert theItem.itemRoot == "0123456789abc"
# Order
theItem.setOrder(None)
assert theItem.itemOrder == 0
@@ -326,6 +338,7 @@ def testCoreItem_XMLPackUnpack(mockGUI, caplog):
theItem = NWItem(theProject)
theItem.setHandle("0123456789abc")
theItem.setParent("0123456789abc")
theItem.setRoot("0123456789abc")
theItem.setOrder(1)
theItem.setName("A Name")
theItem.setClass("NOVEL")
@@ -342,9 +355,11 @@ def testCoreItem_XMLPackUnpack(mockGUI, caplog):
xContent = etree.SubElement(nwXML, "content")
theItem.packXML(xContent)
assert etree.tostring(xContent, pretty_print=False, encoding="utf-8") == (
b'<content><item handle="0123456789abc" parent="0123456789abc" order="1" type="FILE" '
b'class="NOVEL" layout="NOTE"><meta charCount="7" wordCount="5" paraCount="3" '
b'cursorPos="11"/><name status="New" exported="False">A Name</name></item></content>'
b'<content>'
b'<item handle="0123456789abc" parent="0123456789abc" root="0123456789abc" order="1" '
b'type="FILE" class="NOVEL" layout="NOTE"><meta charCount="7" wordCount="5" paraCount="3" '
b'cursorPos="11"/><name status="New" exported="False">A Name</name></item>'
b'</content>'
)
# Unpack
@@ -368,6 +383,7 @@ def testCoreItem_XMLPackUnpack(mockGUI, caplog):
theItem = NWItem(theProject)
theItem.setHandle("0123456789abc")
theItem.setParent("0123456789abc")
theItem.setRoot("0123456789abc")
theItem.setOrder(1)
theItem.setName("A Name")
theItem.setClass("NOVEL")
@@ -385,8 +401,11 @@ def testCoreItem_XMLPackUnpack(mockGUI, caplog):
xContent = etree.SubElement(nwXML, "content")
theItem.packXML(xContent)
assert etree.tostring(xContent, pretty_print=False, encoding="utf-8") == (
b'<content><item handle="0123456789abc" parent="0123456789abc" order="1" type="FOLDER" '
b'class="NOVEL"><meta expanded="True"/><name status="New">A Name</name></item></content>'
b'<content>'
b'<item handle="0123456789abc" parent="0123456789abc" root="0123456789abc" order="1" '
b'type="FOLDER" class="NOVEL"><meta expanded="True"/><name status="New">A Name</name>'
b'</item>'
b'</content>'
)
# Unpack
+22 -19
View File
@@ -374,25 +374,28 @@ def testCoreTree_XMLPackUnpack(mockGUI, mockItems):
assert etree.tostring(nwXML, pretty_print=False, encoding="utf-8") == (
b'<novelWriterXML>'
b'<content count="8">'
b'<item handle="a000000000001" parent="None" order="0" type="ROOT" class="NOVEL">'
b'<meta expanded="True"/><name status="None">Novel</name></item>'
b'<item handle="b000000000001" parent="a000000000001" order="0" type="FOLDER" '
b'class="NOVEL"><meta expanded="True"/><name status="None">Act One</name></item>'
b'<item handle="c000000000001" parent="b000000000001" order="0" type="FILE" class="NOVEL" '
b'layout="DOCUMENT"><meta charCount="300" wordCount="50" paraCount="2" cursorPos="0"/>'
b'<name status="None" exported="True">Chapter One</name></item>'
b'<item handle="c000000000002" parent="b000000000001" order="0" type="FILE" class="NOVEL" '
b'layout="DOCUMENT"><meta charCount="3000" wordCount="500" paraCount="20" cursorPos="0"/>'
b'<name status="None" exported="True">Scene One</name></item>'
b'<item handle="a000000000002" parent="None" order="0" type="ROOT" class="ARCHIVE">'
b'<meta expanded="False"/><name status="None">Outtakes</name></item>'
b'<item handle="a000000000003" parent="None" order="0" type="TRASH" class="TRASH">'
b'<meta expanded="False"/><name status="None">Trash</name></item>'
b'<item handle="a000000000004" parent="None" order="0" type="ROOT" class="CHARACTER">'
b'<meta expanded="True"/><name status="None">Characters</name></item>'
b'<item handle="b000000000002" parent="a000000000002" order="0" type="FILE" '
b'class="CHARACTER" layout="NOTE"><meta charCount="2000" wordCount="400" paraCount="16" '
b'cursorPos="0"/><name status="None" exported="True">Jane Doe</name></item>'
b'<item handle="a000000000001" parent="None" root="a000000000001" order="0" type="ROOT" '
b'class="NOVEL"><meta expanded="True"/><name status="None">Novel</name></item>'
b'<item handle="b000000000001" parent="a000000000001" root="a000000000001" order="0" '
b'type="FOLDER" class="NOVEL"><meta expanded="True"/>'
b'<name status="None">Act One</name></item>'
b'<item handle="c000000000001" parent="b000000000001" root="a000000000001" order="0" '
b'type="FILE" class="NOVEL" layout="DOCUMENT"><meta charCount="300" wordCount="50" '
b'paraCount="2" cursorPos="0"/><name status="None" exported="True">Chapter One</name>'
b'</item>'
b'<item handle="c000000000002" parent="b000000000001" root="a000000000001" order="0" '
b'type="FILE" class="NOVEL" layout="DOCUMENT"><meta charCount="3000" wordCount="500" '
b'paraCount="20" cursorPos="0"/><name status="None" exported="True">Scene One</name>'
b'</item>'
b'<item handle="a000000000002" parent="None" root="a000000000002" order="0" type="ROOT" '
b'class="ARCHIVE"><meta expanded="False"/><name status="None">Outtakes</name></item>'
b'<item handle="a000000000003" parent="None" root="a000000000003" order="0" type="TRASH" '
b'class="TRASH"><meta expanded="False"/><name status="None">Trash</name></item>'
b'<item handle="a000000000004" parent="None" root="a000000000004" order="0" type="ROOT" '
b'class="CHARACTER"><meta expanded="True"/><name status="None">Characters</name></item>'
b'<item handle="b000000000002" parent="a000000000002" root="a000000000002" order="0" '
b'type="FILE" class="CHARACTER" layout="NOTE"><meta charCount="2000" wordCount="400" '
b'paraCount="16" cursorPos="0"/><name status="None" exported="True">Jane Doe</name></item>'
b'</content>'
b'</novelWriterXML>'
)