Add test coverage of status and importance reordering
This commit is contained in:
@@ -175,7 +175,7 @@ class NWStatus():
|
||||
return False
|
||||
|
||||
if order == list(self._store.keys()):
|
||||
return True
|
||||
return False
|
||||
|
||||
store = {}
|
||||
for key in order:
|
||||
|
||||
@@ -464,7 +464,7 @@ class GuiProjectEditStatus(QWidget):
|
||||
nChild = self.listBox.topLevelItemCount()
|
||||
nIndex = tIndex + step
|
||||
if nIndex < 0 or nIndex >= nChild:
|
||||
return False
|
||||
return
|
||||
|
||||
cItem = self.listBox.takeTopLevelItem(tIndex)
|
||||
self.listBox.insertTopLevelItem(nIndex, cItem)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<novelWriterXML appVersion="1.7-alpha0" hexVersion="0x010700a0" fileVersion="1.4" timeStamp="2022-04-16 16:54:15">
|
||||
<novelWriterXML appVersion="1.7-alpha0" hexVersion="0x010700a0" fileVersion="1.4" timeStamp="2022-04-16 18:15:12">
|
||||
<project>
|
||||
<name>Project Name</name>
|
||||
<title>Project Title</title>
|
||||
@@ -42,7 +42,7 @@
|
||||
<entry key="i466852" count="0" red="100" green="100" blue="100">New</entry>
|
||||
<entry key="i3eb13b" count="0" red="200" green="50" blue="0">Minor</entry>
|
||||
<entry key="i392456" count="0" red="200" green="150" blue="0">Major</entry>
|
||||
<entry key="i1a3d1f" count="0" red="0" green="0" blue="0">Final</entry>
|
||||
<entry key="i1a3d1f" count="0" red="100" green="100" blue="100">Final</entry>
|
||||
</importance>
|
||||
</settings>
|
||||
<content count="8">
|
||||
|
||||
@@ -229,6 +229,38 @@ def testCoreStatus_Entries(constData):
|
||||
assert theStatus.count(constData.statusKeys[2]) == 0
|
||||
assert theStatus.count(constData.statusKeys[3]) == 0
|
||||
|
||||
# Reorder
|
||||
# =======
|
||||
|
||||
cOrder = list(theStatus.keys())
|
||||
assert cOrder == constData.statusKeys
|
||||
|
||||
# Wrong length
|
||||
assert theStatus.reorder([]) is False
|
||||
|
||||
# No change
|
||||
assert theStatus.reorder(cOrder) is False
|
||||
|
||||
# Actual reaorder
|
||||
nOrder = [
|
||||
constData.statusKeys[0],
|
||||
constData.statusKeys[2],
|
||||
constData.statusKeys[1],
|
||||
constData.statusKeys[3],
|
||||
]
|
||||
assert theStatus.reorder(nOrder) is True
|
||||
assert list(theStatus.keys()) == nOrder
|
||||
|
||||
# Add an unknown key
|
||||
wOrder = nOrder.copy()
|
||||
wOrder[3] = theStatus._newKey()
|
||||
assert theStatus.reorder(wOrder) is False
|
||||
assert list(theStatus.keys()) == nOrder
|
||||
|
||||
# Put it back
|
||||
assert theStatus.reorder(cOrder) is True
|
||||
assert list(theStatus.keys()) == cOrder
|
||||
|
||||
# Default
|
||||
# =======
|
||||
|
||||
|
||||
@@ -28,9 +28,7 @@ from tools import cmpFiles, getGuiItem
|
||||
|
||||
from PyQt5.QtGui import QColor
|
||||
from PyQt5.QtCore import Qt
|
||||
from PyQt5.QtWidgets import (
|
||||
QDialog, QAction, QMessageBox, QColorDialog, QTreeWidgetItem
|
||||
)
|
||||
from PyQt5.QtWidgets import QDialog, QAction, QMessageBox, QColorDialog
|
||||
|
||||
from novelwriter.dialogs import GuiProjectSettings
|
||||
|
||||
@@ -118,16 +116,6 @@ def testDlgProjSettings_Dialog(
|
||||
assert projEdit.tabStatus.getNewList() == ([], [])
|
||||
assert projEdit.tabStatus.listBox.topLevelItemCount() == 4
|
||||
|
||||
# Fake drag'n'drop should change changed status
|
||||
projEdit.tabStatus._rowsMoved()
|
||||
assert projEdit.tabStatus.colChanged is True
|
||||
projEdit.tabStatus.colChanged = False
|
||||
|
||||
projEdit.tabStatus.listBox.clearSelection()
|
||||
assert projEdit.tabStatus._getSelectedItem() is None
|
||||
projEdit.tabStatus.listBox.topLevelItem(0).setSelected(True)
|
||||
assert isinstance(projEdit.tabStatus._getSelectedItem(), QTreeWidgetItem)
|
||||
|
||||
# Can't delete the first item (it's in use)
|
||||
projEdit.tabStatus.listBox.clearSelection()
|
||||
projEdit.tabStatus.listBox.topLevelItem(0).setSelected(True)
|
||||
@@ -178,6 +166,31 @@ def testDlgProjSettings_Dialog(
|
||||
]
|
||||
)
|
||||
|
||||
# Move items
|
||||
projEdit.tabStatus.listBox.clearSelection()
|
||||
projEdit.tabStatus._moveItem(1)
|
||||
assert [x["key"] for x in projEdit.tabStatus.getNewList()[0]] == [
|
||||
constData.statusKeys[0], constData.statusKeys[1], constData.statusKeys[3], None
|
||||
]
|
||||
|
||||
projEdit.tabStatus.listBox.clearSelection()
|
||||
projEdit.tabStatus.listBox.topLevelItem(0).setSelected(True)
|
||||
projEdit.tabStatus._moveItem(-1)
|
||||
assert [x["key"] for x in projEdit.tabStatus.getNewList()[0]] == [
|
||||
constData.statusKeys[0], constData.statusKeys[1], constData.statusKeys[3], None
|
||||
]
|
||||
|
||||
projEdit.tabStatus.listBox.clearSelection()
|
||||
projEdit.tabStatus.listBox.topLevelItem(3).setSelected(True)
|
||||
projEdit.tabStatus._moveItem(-1)
|
||||
assert [x["key"] for x in projEdit.tabStatus.getNewList()[0]] == [
|
||||
constData.statusKeys[0], constData.statusKeys[1], None, constData.statusKeys[3]
|
||||
]
|
||||
projEdit.tabStatus._moveItem(1)
|
||||
assert [x["key"] for x in projEdit.tabStatus.getNewList()[0]] == [
|
||||
constData.statusKeys[0], constData.statusKeys[1], constData.statusKeys[3], None
|
||||
]
|
||||
|
||||
# Importance Tab
|
||||
# ==============
|
||||
|
||||
|
||||
Reference in New Issue
Block a user