Merge branch 'main' into dev

This commit is contained in:
Veronica K. B. Olsen
2021-01-17 20:58:15 +01:00
5 changed files with 71 additions and 36 deletions
+26 -1
View File
@@ -25,7 +25,8 @@ import pytest
from nw.common import (
checkString, checkBool, checkInt, colRange, formatInt, transferCase,
fuzzyTime, checkHandle, formatTimeStamp, formatTime
fuzzyTime, checkHandle, formatTimeStamp, formatTime, hexToInt,
makeFileNameSafe
)
from tools import cmpList
@@ -87,6 +88,19 @@ def testBaseCommon_CheckHandle():
# END Test testBaseCommon_CheckHandle
@pytest.mark.base
def testBaseCommon_HexToInt():
"""Test the hexToInt function.
"""
assert hexToInt(1) == 0
assert hexToInt("1") == 1
assert hexToInt("0xff") == 255
assert hexToInt("0xffff") == 65535
assert hexToInt("0xffffq") == 0
assert hexToInt("0xffffq", 12) == 12
# END Test testBaseCommon_HexToInt
@pytest.mark.base
def testBaseCommon_ColRange():
"""Test the colRange function.
@@ -210,3 +224,14 @@ def testBaseCommon_FuzzyTime():
assert fuzzyTime(47336400) == "2 years ago"
# END Test testBaseCommon_FuzzyTime
@pytest.mark.base
def testBaseCommon_MakeFileNameSafe():
"""Test the fuzzyTime function.
"""
assert makeFileNameSafe(" aaaa ") == "aaaa"
assert makeFileNameSafe("aaaa,bbbb") == "aaaabbbb"
assert makeFileNameSafe("aaaa\tbbbb") == "aaaabbbb"
assert makeFileNameSafe("aaaa bbbb") == "aaaa bbbb"
# END Test testBaseCommon_MakeFileNameSafe