mirror of
https://gitlab.com/dslackw/slpkg.git
synced 2024-12-27 09:58:10 +01:00
Added tests
Signed-off-by: Dimitris Zlatanidis <d.zlatanidis@gmail.com>
This commit is contained in:
parent
be508cfea4
commit
830f54b069
3 changed files with 24 additions and 6 deletions
|
@ -25,6 +25,7 @@
|
|||
def units(comp_sum, uncomp_sum):
|
||||
"""Calculate package size
|
||||
"""
|
||||
print(comp_sum, uncomp_sum)
|
||||
compressed = round((sum(map(float, comp_sum)) / 1024), 2)
|
||||
uncompressed = round((sum(map(float, uncomp_sum)) / 1024), 2)
|
||||
comp_unit = uncomp_unit = "Mb"
|
||||
|
@ -40,4 +41,5 @@ def units(comp_sum, uncomp_sum):
|
|||
if uncompressed < 1:
|
||||
uncompressed = sum(map(int, uncomp_sum))
|
||||
uncomp_unit = "Kb"
|
||||
return [comp_unit, uncomp_unit], [compressed, uncompressed]
|
||||
print(comp_unit, uncomp_unit, compressed, uncompressed)
|
||||
return [comp_unit, uncomp_unit], [compressed, uncompressed]
|
|
@ -23,6 +23,7 @@
|
|||
|
||||
|
||||
import os
|
||||
from collections import OrderedDict
|
||||
|
||||
from slpkg.splitting import split_package
|
||||
|
||||
|
@ -50,11 +51,7 @@ class Utils:
|
|||
def remove_dbs(self, double):
|
||||
"""Remove double item from list
|
||||
"""
|
||||
one = []
|
||||
for dup in double:
|
||||
if dup not in one:
|
||||
one.append(dup)
|
||||
return one
|
||||
return list(OrderedDict.fromkeys(double))
|
||||
|
||||
def read_file(self, registry):
|
||||
"""Returns reading file
|
||||
|
|
|
@ -1,10 +1,29 @@
|
|||
from slpkg.md5sum import md5
|
||||
from slpkg.sizes import units
|
||||
from slpkg.utils import Utils
|
||||
|
||||
|
||||
def test_md5_superuser():
|
||||
result = md5('slpkg/superuser.py')
|
||||
assert result == "e6cebdf37fbc1b8e9d3c5e3e53b300c1"
|
||||
|
||||
|
||||
def test_md5_security():
|
||||
result = md5('slpkg/security.py')
|
||||
assert result == "d395d2fcf1c7b1a91ef6ce3dc8eb047b"
|
||||
|
||||
|
||||
def test_units():
|
||||
assert ["Kb", "Kb"], ["100", "100"] == units(['100', ['100']])
|
||||
|
||||
|
||||
def test_dimensional_list():
|
||||
lists = [[1, 2, 3, 4, 5]]
|
||||
utils = Utils()
|
||||
assert [1, 2, 3, 4, 5] == utils.dimensional_list(lists)
|
||||
|
||||
|
||||
def test_remove_dbs():
|
||||
lists = [1, 2, 3, 3, 4, 5, 2, 1]
|
||||
utils = Utils()
|
||||
assert [1, 2, 3, 4, 5] == utils.remove_dbs(lists)
|
Loading…
Reference in a new issue