Added a new formatTime function to common, and replaced similar functions in other classes

This commit is contained in:
Veronica K. B. Olsen
2020-10-23 20:26:29 +02:00
parent 78a0a595b9
commit 170c2dc19c
4 changed files with 43 additions and 33 deletions
+20 -2
View File
@@ -7,7 +7,7 @@ import pytest
from nw.common import (
checkString, checkBool, checkInt, colRange, formatInt, transferCase,
fuzzyTime, checkHandle, formatTimeStamp
fuzzyTime, checkHandle, formatTimeStamp, formatTime
)
from nwtools import cmpList
@@ -78,11 +78,29 @@ def testColRange():
)
@pytest.mark.core
def testFormatTime():
def testFormatTimeStamp():
tTime = time.mktime(time.gmtime(0))
assert formatTimeStamp(tTime, False) == "1970-01-01 00:00:00"
assert formatTimeStamp(tTime, True) == "1970-01-01 00.00.00"
@pytest.mark.core
def testFormatTime():
assert formatTime("1") == "ERROR"
assert formatTime(1.0) == "ERROR"
assert formatTime(1) == "00:00:01"
assert formatTime(59) == "00:00:59"
assert formatTime(60) == "00:01:00"
assert formatTime(180) == "00:03:00"
assert formatTime(194) == "00:03:14"
assert formatTime(3540) == "00:59:00"
assert formatTime(3599) == "00:59:59"
assert formatTime(3600) == "01:00:00"
assert formatTime(11640) == "03:14:00"
assert formatTime(11655) == "03:14:15"
assert formatTime(86399) == "23:59:59"
assert formatTime(86400) == "1-00:00:00"
assert formatTime(360000) == "4-04:00:00"
@pytest.mark.core
def testFormatInt():
assert formatInt(1000) == "1000"