Fix warnings in tests

This commit is contained in:
Veronica Berglyd Olsen
2025-01-13 19:43:04 +01:00
parent 72ed5d84f6
commit 0b7c31b6a9
11 changed files with 336 additions and 102 deletions
+217 -56
View File
@@ -125,14 +125,37 @@ def testToolWritingStats_Export(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
assert sessLog.notesWords.text() == "{:n}".format(275)
assert sessLog.totalWords.text() == "{:n}".format(875)
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(-200)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(300)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(-120)
assert sessLog.listBox.topLevelItem(4).text(sessLog.C_COUNT) == "{:n}".format(-20)
assert sessLog.listBox.topLevelItem(5).text(sessLog.C_COUNT) == "{:n}".format(40)
assert sessLog.listBox.topLevelItem(6).text(sessLog.C_COUNT) == "{:n}".format(-400)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_COUNT) == "{:n}".format(200)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-120)
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert sessLog._saveData(sessLog.FMT_CSV)
assert sessLog._saveData(sessLog.FMT_JSON)
@@ -205,14 +228,37 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
sessLog.populateGUI()
sessLog.listBox.sortByColumn(sessLog.C_TIME, Qt.SortOrder.AscendingOrder)
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(-200)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(300)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(-120)
assert sessLog.listBox.topLevelItem(4).text(sessLog.C_COUNT) == "{:n}".format(-20)
assert sessLog.listBox.topLevelItem(5).text(sessLog.C_COUNT) == "{:n}".format(40)
assert sessLog.listBox.topLevelItem(6).text(sessLog.C_COUNT) == "{:n}".format(-400)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_COUNT) == "{:n}".format(200)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-120)
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
# No Novel Files
qtbot.mouseClick(sessLog.incNovel, QtMouseLeft)
@@ -222,14 +268,37 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
jsonData = json.loads(inFile.read())
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(-100)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(150)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(-60)
assert sessLog.listBox.topLevelItem(4).text(sessLog.C_COUNT) == "{:n}".format(-10)
assert sessLog.listBox.topLevelItem(5).text(sessLog.C_COUNT) == "{:n}".format(20)
assert sessLog.listBox.topLevelItem(6).text(sessLog.C_COUNT) == "{:n}".format(-200)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_COUNT) == "{:n}".format(100)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-100)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(150)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-60)
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-10)
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(20)
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(100)
assert jsonData == [
{
@@ -268,14 +337,37 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
jsonData = json.load(inFile)
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(-100)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(150)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(-60)
assert sessLog.listBox.topLevelItem(4).text(sessLog.C_COUNT) == "{:n}".format(-10)
assert sessLog.listBox.topLevelItem(5).text(sessLog.C_COUNT) == "{:n}".format(20)
assert sessLog.listBox.topLevelItem(6).text(sessLog.C_COUNT) == "{:n}".format(-200)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_COUNT) == "{:n}".format(100)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-100)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(150)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-60)
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-10)
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(20)
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(100)
assert jsonData == [
{
@@ -314,10 +406,21 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
jsonData = json.load(inFile)
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(300)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(40)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(200)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
assert jsonData == [
{
@@ -344,16 +447,45 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
jsonData = json.load(inFile)
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(0)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(-200)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(300)
assert sessLog.listBox.topLevelItem(4).text(sessLog.C_COUNT) == "{:n}".format(-120)
assert sessLog.listBox.topLevelItem(5).text(sessLog.C_COUNT) == "{:n}".format(-20)
assert sessLog.listBox.topLevelItem(6).text(sessLog.C_COUNT) == "{:n}".format(40)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_COUNT) == "{:n}".format(-400)
assert sessLog.listBox.topLevelItem(8).text(sessLog.C_COUNT) == "{:n}".format(200)
assert sessLog.listBox.topLevelItem(9).text(sessLog.C_COUNT) == "{:n}".format(0)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(0)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(300)
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-120)
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
item = sessLog.listBox.topLevelItem(8)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
item = sessLog.listBox.topLevelItem(9)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(0)
assert jsonData == [
{
@@ -390,9 +522,15 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
]
# Toggle Idle Time
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_IDLE) == "4 %"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_IDLE) == "4 %"
qtbot.mouseClick(sessLog.showIdleTime, QtMouseLeft)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_IDLE) == "00:01:10"
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_IDLE) == "00:01:10"
# Group by Day
qtbot.mouseClick(sessLog.groupByDay, QtMouseLeft)
@@ -402,14 +540,37 @@ def testToolWritingStats_Filters(qtbot, monkeypatch, nwGUI, projPath, tstPaths):
with open(jsonStats, mode="r", encoding="utf-8") as inFile:
jsonData = json.load(inFile)
assert sessLog.listBox.topLevelItem(0).text(sessLog.C_COUNT) == "{:n}".format(1)
assert sessLog.listBox.topLevelItem(1).text(sessLog.C_COUNT) == "{:n}".format(-200)
assert sessLog.listBox.topLevelItem(2).text(sessLog.C_COUNT) == "{:n}".format(180)
assert sessLog.listBox.topLevelItem(3).text(sessLog.C_COUNT) == "{:n}".format(-20)
assert sessLog.listBox.topLevelItem(4).text(sessLog.C_COUNT) == "{:n}".format(40)
assert sessLog.listBox.topLevelItem(5).text(sessLog.C_COUNT) == "{:n}".format(-400)
assert sessLog.listBox.topLevelItem(6).text(sessLog.C_COUNT) == "{:n}".format(200)
assert sessLog.listBox.topLevelItem(7).text(sessLog.C_COUNT) == "{:n}".format(0)
item = sessLog.listBox.topLevelItem(0)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(1)
item = sessLog.listBox.topLevelItem(1)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-200)
item = sessLog.listBox.topLevelItem(2)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(180)
item = sessLog.listBox.topLevelItem(3)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-20)
item = sessLog.listBox.topLevelItem(4)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(40)
item = sessLog.listBox.topLevelItem(5)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(-400)
item = sessLog.listBox.topLevelItem(6)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(200)
item = sessLog.listBox.topLevelItem(7)
assert item is not None
assert item.text(sessLog.C_COUNT) == "{:n}".format(0)
assert jsonData == [
{