Fix tests
This commit is contained in:
@@ -859,12 +859,12 @@ def testCoreProject_Methods(monkeypatch, nwMinimal, dummyGUI, tmpDir):
|
||||
|
||||
# Session stats
|
||||
monkeypatch.setattr("os.path.isdir", lambda *args, **kwargs: False)
|
||||
assert not theProject._appendSessionStats()
|
||||
assert not theProject._appendSessionStats(idleTime=0)
|
||||
monkeypatch.undo()
|
||||
|
||||
# Block open
|
||||
monkeypatch.setattr("builtins.open", causeOSError)
|
||||
assert not theProject._appendSessionStats()
|
||||
assert not theProject._appendSessionStats(idleTime=0)
|
||||
monkeypatch.undo()
|
||||
|
||||
# Write entry
|
||||
@@ -876,13 +876,13 @@ def testCoreProject_Methods(monkeypatch, nwMinimal, dummyGUI, tmpDir):
|
||||
theProject.notesWCount = 100
|
||||
|
||||
monkeypatch.setattr("nw.core.project.time", lambda: 1600005600)
|
||||
assert theProject._appendSessionStats()
|
||||
assert theProject._appendSessionStats(idleTime=99)
|
||||
monkeypatch.undo()
|
||||
|
||||
assert readFile(statsFile) == (
|
||||
"# Offset 100\n"
|
||||
"# Start Time End Time Novel Notes\n"
|
||||
"%s %s 200 100\n"
|
||||
"# Start Time End Time Novel Notes Idle\n"
|
||||
"%s %s 200 100 99\n"
|
||||
) % (formatTimeStamp(1600002000), formatTimeStamp(1600005600))
|
||||
|
||||
# Pack XML Value
|
||||
|
||||
@@ -72,7 +72,7 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
# Make a test log file
|
||||
writeFile(sessFile, (
|
||||
"# Offset 123\n"
|
||||
"# Start Time End Time Novel Notes\n"
|
||||
"# Start Time End Time Novel Notes Idle\n"
|
||||
"2020-01-01 21:00:00 2020-01-01 21:00:05 6 0\n"
|
||||
"2020-01-03 21:00:00 2020-01-03 21:00:15 125 0\n"
|
||||
"2020-01-03 21:30:00 2020-01-03 21:30:15 125 5\n"
|
||||
@@ -86,8 +86,8 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
# Make sure a faulty file can still be read
|
||||
writeFile(sessFile, (
|
||||
"# Offset abc123\n"
|
||||
"# Start Time End Time Novel Notes\n"
|
||||
"2020-01-01 21:00:00 2020-01-01 21:00:05 6 0\n"
|
||||
"# Start Time End Time Novel Notes Idle\n"
|
||||
"2020-01-01 21:00:00 2020-01-01 21:00:05 6 0 50\n"
|
||||
"2020-01-03 21:00:00 2020-01-03 21:00:15 125 0\n"
|
||||
"2020-01-03 21:30:00 2020-01-03 21:30:15 125 5\n"
|
||||
"2020-01-06 21:00:00 2020-01-06 21:00:10 125\n"
|
||||
@@ -100,8 +100,8 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
# ==============
|
||||
|
||||
writeFile(sessFile, (
|
||||
"# Start Time End Time Novel Notes\n"
|
||||
"2020-01-01 21:00:00 2020-01-01 21:00:05 6 0\n"
|
||||
"# Start Time End Time Novel Notes Idle\n"
|
||||
"2020-01-01 21:00:00 2020-01-01 21:00:05 6 0 50\n"
|
||||
"2020-01-03 21:00:00 2020-01-03 21:00:15 125 0\n"
|
||||
"2020-01-03 21:30:00 2020-01-03 21:30:15 125 5\n"
|
||||
"2020-01-06 21:00:00 2020-01-06 21:00:10 125 5\n"
|
||||
@@ -133,10 +133,17 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
jsonData = json.load(inFile)
|
||||
|
||||
assert len(jsonData) == 4
|
||||
assert jsonData[0]["length"] >= 4.0
|
||||
assert jsonData[0]["newWords"] == 6
|
||||
assert jsonData[0]["novelWords"] == 6
|
||||
assert jsonData[0]["noteWords"] == 0
|
||||
assert jsonData[0]["idleTime"] == 50
|
||||
|
||||
assert jsonData[1]["length"] >= 14.0
|
||||
assert jsonData[1]["newWords"] == 119
|
||||
assert jsonData[1]["novelWords"] == 125
|
||||
assert jsonData[1]["noteWords"] == 0
|
||||
assert jsonData[1]["idleTime"] == 0
|
||||
|
||||
# Test Filters
|
||||
# ============
|
||||
@@ -160,6 +167,7 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
assert jsonData[0]["newWords"] == 5
|
||||
assert jsonData[0]["novelWords"] == 125
|
||||
assert jsonData[0]["noteWords"] == 5
|
||||
assert jsonData[0]["idleTime"] == 0
|
||||
|
||||
# No Note Files
|
||||
qtbot.mouseClick(sessLog.incNovel, Qt.LeftButton)
|
||||
@@ -177,6 +185,7 @@ def testGuiWritingStats_Dialog(qtbot, monkeypatch, nwGUI, fncDir, fncProj):
|
||||
assert jsonData[1]["newWords"] == 119
|
||||
assert jsonData[1]["novelWords"] == 125
|
||||
assert jsonData[1]["noteWords"] == 0
|
||||
assert jsonData[1]["idleTime"] == 0
|
||||
|
||||
# No Negative Entries
|
||||
qtbot.mouseClick(sessLog.incNotes, Qt.LeftButton)
|
||||
|
||||
Reference in New Issue
Block a user