Switch to unittest

Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
Dimitris Zlatanidis 2022-04-24 20:03:25 +03:00
parent 515d0d3b47
commit 055786a6a0
4 changed files with 66 additions and 35 deletions

View file

@ -1,12 +1,19 @@
import unittest
from slpkg.file_size import FileSize
def test_FileSize():
"""Testing the remote and local servers
"""
url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
lc = "tests/test_units.py"
fs1 = FileSize(url)
fs2 = FileSize(lc)
assert fs1.server() is not None
assert fs2.local() is not None
class TestFileSize(unittest.TestCase):
def test_FileSize(self):
"""Testing the remote and local servers
"""
url = "https://mirrors.slackware.com/slackware/slackware64-14.2/ChangeLog.txt"
lc = "test_units.py"
fs1 = FileSize(url)
fs2 = FileSize(lc)
self.assertIsNotNone(fs1.server())
self.assertIsNotNone(fs2.local())
if __name__ == "__main__":
unittest.main()

View file

@ -1,15 +1,21 @@
import unittest
from slpkg.md5sum import md5
def test_md5_superuser():
"""Testing checksum for superuser.py file
"""
result = md5('slpkg/superuser.py')
assert result == "c6a3576c247bda199c75b43540bfc3d7"
class TestMd5(unittest.TestCase):
def test_md5_superuser(self):
"""Testing checksum for superuser.py file
"""
result = md5('test_file_size.py')
self.assertEqual(result, "e3e7b72be80efc922b0e1f1cd409a417")
def test_md5_security(self):
"""Testing checksum for security.py file
"""
result = md5('test_units.py')
self.assertEqual(result, "0f6bb6ac5282498db65a791e28f207fe")
def test_md5_security():
"""Testing checksum for security.py file
"""
result = md5('slpkg/security.py')
assert result == "eb8dbea4dec6d72353d30475670389f0"
if __name__ == "__main__":
unittest.main()

View file

@ -1,7 +1,19 @@
import unittest
from slpkg.sizes import units
def test_units():
"""Testing the units metrics
"""
assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']])
class TetsUnits(unittest.TestCase):
def test_units(self):
"""Testing the units metrics
"""
self.assertCountEqual((["Kb", "Kb"], [100, 100]),
units(["100"], ["100"]))
self.assertCountEqual((["Mb", "Mb"], [1000, 1000]),
units(["1024000"], ["1024000"]))
self.assertCountEqual((["Gb", "Gb"], [976.56, 976.56]),
units(["1024000000"], ["1024000000"]))
if __name__ == "__main__":
unittest.main()

View file

@ -1,17 +1,23 @@
import unittest
from slpkg.utils import Utils
def test_dimensional_list():
"""Testing dimesional list util
"""
lists = [[1, 2, 3, 4, 5]]
utils = Utils()
assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists)
class TestUtils(unittest.TestCase):
def test_dimensional_list(self):
"""Testing dimesional list util
"""
lists = [[1, 2, 3, 4, 5]]
utils = Utils()
self.assertEqual([1, 2, 3, 4, 5], utils.dimensional_list(lists))
def test_remove_dbs(self):
"""Testing removing doubles item from list
"""
lists = [1, 2, 3, 3, 4, 5, 2, 1]
utils = Utils()
self.assertEqual([1, 2, 3, 4, 5], utils.remove_dbs(lists))
def test_remove_dbs():
"""Testing removing doubles item from list
"""
lists = [1, 2, 3, 3, 4, 5, 2, 1]
utils = Utils()
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)
if __name__ == "__main__":
unittest.main()