mirror of
https://github.com/botlabsDev/npkpy.git
synced 2026-01-27 22:57:16 +01:00
refactored code
This commit is contained in:
parent
a1259a7e83
commit
93a26c0e1b
20 changed files with 73 additions and 150 deletions
|
|
@ -1,4 +1,4 @@
|
|||
#!/bin/bash
|
||||
|
||||
pytest --cov=npkpy --cov=tests_acceptance_test -v
|
||||
pylint --rcfile=.pylintrc npkpy/**
|
||||
pylint --rcfile=.pylintrc npkpy/** tests/** tests_acceptance_test/**
|
||||
|
|
|
|||
|
|
@ -3,21 +3,19 @@ import unittest
|
|||
|
||||
from npkpy.common import NPKError
|
||||
from npkpy.npk.cnt_basic import CntBasic
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_CntBasic(unittest.TestCase):
|
||||
|
||||
def setUp(self) -> None:
|
||||
self.cnt = CntBasic(data=DummyBasicCnt().cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntBasic(data=get_dummy_basic_cnt(), offset_in_pck=0)
|
||||
|
||||
def test_extractCntId(self):
|
||||
self.assertEqual(-1, self.cnt.cnt_id)
|
||||
|
||||
def test_failForWrongCntId(self):
|
||||
dummy_cnt = DummyBasicCnt()
|
||||
dummy_cnt._00_cnt_id = struct.pack("h", 999)
|
||||
cnt = CntBasic(dummy_cnt.cnt_full_binary, offset_in_pck=0)
|
||||
cnt = CntBasic(get_dummy_basic_cnt(cnt_id=999), offset_in_pck=0)
|
||||
with self.assertRaises(NPKError) as _exception:
|
||||
_ = cnt.cnt_id
|
||||
self.assertEqual("Cnt object does not represent given container typ -1/999", _exception.exception.args[0])
|
||||
|
|
@ -32,7 +30,7 @@ class Test_CntBasic(unittest.TestCase):
|
|||
self.assertEqual(b"Payload", self.cnt.cnt_payload)
|
||||
|
||||
def test_extractCntFromGivenOffset(self):
|
||||
self.assertEqual(len(DummyBasicCnt().cnt_full_binary), self.cnt.cnt_full_length)
|
||||
self.assertEqual(len(get_dummy_basic_cnt()), self.cnt.cnt_full_length)
|
||||
|
||||
def test_giveOverviewOfCnt(self):
|
||||
expected_result = ('CntBasic', ['Cnt id: -1',
|
||||
|
|
@ -43,12 +41,12 @@ class Test_CntBasic(unittest.TestCase):
|
|||
self.assertEqual(expected_result, self.cnt.output_cnt)
|
||||
|
||||
def test_getFullBinaryOfContainer(self):
|
||||
self.assertEqual(DummyBasicCnt().cnt_full_binary, self.cnt.cnt_full_binary)
|
||||
self.assertEqual(get_dummy_basic_cnt(), self.cnt.cnt_full_binary)
|
||||
|
||||
|
||||
class Test_modifyNpkContainerBasic(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.cnt = CntBasic(DummyBasicCnt().cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntBasic(get_dummy_basic_cnt(), offset_in_pck=0)
|
||||
|
||||
def test_increaseCntSize(self):
|
||||
orig_cnt_full_length = self.cnt.cnt_full_length
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_flag_a import CntFlagA
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntFlagA(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 7)
|
||||
|
||||
self.cnt = CntFlagA(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntFlagA(get_dummy_basic_cnt(cnt_id=7), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(7, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_flag_b import CntFlagB
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntFlagB(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 8)
|
||||
|
||||
self.cnt = CntFlagB(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntFlagB(get_dummy_basic_cnt(cnt_id=8), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(8, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_flag_c import CntFlagC
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntFlagC(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 17)
|
||||
|
||||
self.cnt = CntFlagC(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntFlagC(get_dummy_basic_cnt(cnt_id=17), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(17, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_mpls import CntMpls
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntMpls(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 19)
|
||||
|
||||
self.cnt = CntMpls(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntMpls(get_dummy_basic_cnt(cnt_id=19), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(19, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_null_block import CntNullBlock
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntNullBlock(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 22)
|
||||
|
||||
self.cnt = CntNullBlock(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntNullBlock(get_dummy_basic_cnt(cnt_id=22), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(22, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_squasfs_image import CntSquashFsImage
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntSquashFsImage(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 21)
|
||||
self.cnt = CntSquashFsImage(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntSquashFsImage(get_dummy_basic_cnt(cnt_id=21), offset_in_pck=0)
|
||||
|
||||
self.expectedHash = b'\xc3\x04\x15\xea\xccjYDit\xb7\x16\xef\xf5l\xf2\x82\x19\x81]'
|
||||
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_squashfs_hash_signature import CntSquashFsHashSignature
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntSquashFsHashSignature(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 9)
|
||||
self.cnt = CntSquashFsHashSignature(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntSquashFsHashSignature(get_dummy_basic_cnt(cnt_id=9), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(9, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.cnt_zlib_compressed_data import CntZlibDompressedData
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cntZlibCompressedData(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 4)
|
||||
self.cnt = CntZlibDompressedData(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = CntZlibDompressedData(get_dummy_basic_cnt(cnt_id=4), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(4, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path, PosixPath
|
||||
from pathlib import Path
|
||||
from unittest.mock import Mock
|
||||
|
||||
from npkpy.common import get_short_pkt_info, get_short_cnt_info, get_all_nkp_files, write_to_file, extract_container, \
|
||||
get_full_cnt_info, get_full_pkt_info, sha1_sum_from_binary, sha1_sum_from_file
|
||||
from npkpy.npk.cnt_basic import CntBasic
|
||||
from npkpy.npk.npk import Npk
|
||||
from npkpy.npk.npk_constants import CNT_HANDLER
|
||||
from npkpy.npk.pck_header import NPK_PCK_HEADER
|
||||
from tests.constants import DummyBasicCnt, get_dummy_npk_binary, DummyHeaderCnt
|
||||
from tests.constants import get_dummy_npk_binary, DummyHeaderCnt, get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_findNpkFiles(unittest.TestCase):
|
||||
|
|
@ -72,8 +71,8 @@ class Common_Test(unittest.TestCase):
|
|||
self.output_folder.mkdir()
|
||||
|
||||
def tearDown(self) -> None:
|
||||
def delete_directory(dir):
|
||||
for _file in dir.rglob("*"):
|
||||
def delete_directory(folder):
|
||||
for _file in folder.rglob("*"):
|
||||
if _file.is_file():
|
||||
_file.unlink()
|
||||
else:
|
||||
|
|
@ -122,7 +121,7 @@ class Common_Test(unittest.TestCase):
|
|||
self.assertEqual(DummyHeaderCnt()._02_payload, created_files[0].read_bytes())
|
||||
|
||||
def test_getFullCntInfo_asString(self):
|
||||
result = get_full_cnt_info(CntBasic(DummyBasicCnt().cnt_full_binary, offset_in_pck=0))
|
||||
result = get_full_cnt_info(CntBasic(get_dummy_basic_cnt(), offset_in_pck=0))
|
||||
|
||||
self.assertEqual(['CntBasic',
|
||||
' Cnt id: -1',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
# HEADER
|
||||
import struct
|
||||
|
||||
from npkpy.npk.pck_header import NPK_PCK_HEADER
|
||||
|
|
@ -85,7 +84,8 @@ class DummyHeaderCnt:
|
|||
self._02_payloadSpecialFlag
|
||||
|
||||
|
||||
class DummyRequirementsHeader:
|
||||
# pylint: disable=too-many-locals
|
||||
def get_dummy_requirements_header(structId):
|
||||
_00_cnt_id = struct.pack("H", 3)
|
||||
_01_cnt_payload_len = struct.pack("I", 35)
|
||||
_02_cnt_struct_id = struct.pack("H", 0)
|
||||
|
|
@ -105,53 +105,27 @@ class DummyRequirementsHeader:
|
|||
|
||||
_13_cnt_flags = struct.pack("5B", 0, 0, 0, 0, 0)
|
||||
|
||||
def __init__(self, structId):
|
||||
self._02_cnt_struct_id = struct.pack(b"H", structId)
|
||||
|
||||
@property
|
||||
def get_binary(self):
|
||||
return (self._00_cnt_id +
|
||||
self._01_cnt_payload_len +
|
||||
self._02_payload
|
||||
def _build_payload():
|
||||
return (_02_cnt_struct_id +
|
||||
_03_cnt_program_name +
|
||||
_04_cnt_min_versionRevision +
|
||||
_05_cnt_min_versionRc +
|
||||
_06_cnt_min_versionMinor +
|
||||
_07_cnt_min_versionMajor +
|
||||
_08_cnt_nullBock +
|
||||
_09_cnt_max_versionRevision +
|
||||
_10_cnt_max_versionRc +
|
||||
_11_cnt_max_versionMinor +
|
||||
_12_cnt_max_versionMajor +
|
||||
_13_cnt_flags
|
||||
)
|
||||
|
||||
@property
|
||||
def _02_payload(self):
|
||||
return (self._02_cnt_struct_id +
|
||||
self._03_cnt_program_name +
|
||||
self._04_cnt_min_versionRevision +
|
||||
self._05_cnt_min_versionRc +
|
||||
self._06_cnt_min_versionMinor +
|
||||
self._07_cnt_min_versionMajor +
|
||||
self._08_cnt_nullBock +
|
||||
self._09_cnt_max_versionRevision +
|
||||
self._10_cnt_max_versionRc +
|
||||
self._11_cnt_max_versionMinor +
|
||||
self._12_cnt_max_versionMajor +
|
||||
self._13_cnt_flags
|
||||
)
|
||||
_02_cnt_struct_id = struct.pack(b"H", structId)
|
||||
return (_00_cnt_id + _01_cnt_payload_len + _build_payload())
|
||||
|
||||
|
||||
class DummyBasicCnt:
|
||||
_00_cnt_id = struct.pack("h", -1)
|
||||
def get_dummy_basic_cnt(cnt_id=-1):
|
||||
_00_cnt_id = struct.pack("h", cnt_id)
|
||||
_02_cnt_payload = struct.pack("7s", b"Payload")
|
||||
_01_cnt_payload_len = struct.pack("I", len(_02_cnt_payload))
|
||||
|
||||
@property
|
||||
def cnt_full_binary(self):
|
||||
return self._00_cnt_id + \
|
||||
self._01_cnt_payload_len + \
|
||||
self._02_cnt_payload
|
||||
|
||||
|
||||
class DummyMulticontainer_Header:
|
||||
payload = b"d" * 28 + b"0" * 4
|
||||
_00_cnt_id = struct.pack("h", 18)
|
||||
_01_cnt_payload_len = struct.pack("I", len(payload))
|
||||
_02_cnt_payload = struct.pack(f"{len(payload)}s", payload)
|
||||
|
||||
@property
|
||||
def cnt_full_binary(self):
|
||||
return self._00_cnt_id + \
|
||||
self._01_cnt_payload_len + \
|
||||
self._02_cnt_payload
|
||||
return _00_cnt_id + _01_cnt_payload_len + _02_cnt_payload
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import unittest
|
||||
|
||||
from npkpy.npk.npk_constants import CNT_HANDLER
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_npkConstants(unittest.TestCase):
|
||||
|
|
@ -9,6 +9,6 @@ class Test_npkConstants(unittest.TestCase):
|
|||
def test_validateAssignment_DictIdIsContainerId(self):
|
||||
for cnt_id, cnt_class in CNT_HANDLER.items():
|
||||
if cnt_class != "?":
|
||||
cnt = cnt_class(DummyBasicCnt().cnt_full_binary, 0)
|
||||
cnt = cnt_class(get_dummy_basic_cnt(), 0)
|
||||
self.assertEqual(cnt_id, cnt._regular_cnt_id,
|
||||
msg=f"{cnt_id}!={cnt._regular_cnt_id}")
|
||||
|
|
|
|||
|
|
@ -33,6 +33,6 @@ class FileInfo_Test(unittest.TestCase):
|
|||
def test_filenameArchitecture_returnDefaultIfNotMentionedInFilename(self):
|
||||
self.assertEqual("x86", self.file.filename_architecture)
|
||||
|
||||
def test_filenameArchitecture_returnDefaultIfNotMentionedInFilename(self):
|
||||
def test_filenameArchitecture_validateArchitectures(self):
|
||||
for arch in ARCHITECTURES:
|
||||
self.assertEqual(arch, (FileBasic(Path(f"file-name-1.2.3-{arch}.npk")).filename_architecture))
|
||||
self.assertEqual(arch, FileBasic(Path(f"file-name-1.2.3-{arch}.npk")).filename_architecture)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.pck_description import PckDescription
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_pckDescription(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 2)
|
||||
|
||||
self.cnt = PckDescription(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = PckDescription(get_dummy_basic_cnt(cnt_id=2), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(2, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.pck_eckcdsa_hash import PckEckcdsaHash
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_pckEckcdsaHash(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummyCnt = DummyBasicCnt()
|
||||
dummyCnt._00_cnt_id = struct.pack("h", 23)
|
||||
|
||||
self.cnt = PckEckcdsaHash(dummyCnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = PckEckcdsaHash(get_dummy_basic_cnt(cnt_id=23), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(23, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import struct
|
|||
import unittest
|
||||
|
||||
from npkpy.npk.pck_header import PckHeader
|
||||
from npkpy.npk.pck_multicontainer_header import PktMulticontainerHeader
|
||||
from tests.constants import DummyHeaderCnt
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.pck_multicontainer_list import PktMulticontainerList
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_cnt_MultiContainerList(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummy_cnt = DummyBasicCnt()
|
||||
dummy_cnt._00_cnt_id = struct.pack("h", 20)
|
||||
|
||||
self.cnt = PktMulticontainerList(dummy_cnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = PktMulticontainerList(get_dummy_basic_cnt(cnt_id=20), offset_in_pck=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(20, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,16 +1,12 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.pck_release_typ import PckReleaseTyp
|
||||
from tests.constants import DummyBasicCnt
|
||||
from tests.constants import get_dummy_basic_cnt
|
||||
|
||||
|
||||
class Test_pckReleaseTyp(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
dummy_cnt = DummyBasicCnt()
|
||||
dummy_cnt._00_cnt_id = struct.pack("h", 24)
|
||||
|
||||
self.cnt = PckReleaseTyp(dummy_cnt.cnt_full_binary, offset_in_pck=0)
|
||||
self.cnt = PckReleaseTyp(get_dummy_basic_cnt(cnt_id=24), offset_in_pck=0)
|
||||
|
||||
def test_validate_cnt_id(self):
|
||||
self.assertEqual(24, self.cnt.cnt_id)
|
||||
|
|
|
|||
|
|
@ -1,26 +1,25 @@
|
|||
import struct
|
||||
import unittest
|
||||
|
||||
from npkpy.npk.pck_requirements_header import PckRequirementsHeader
|
||||
from tests.constants import DummyHeaderCnt, DummyRequirementsHeader
|
||||
from tests.constants import get_dummy_requirements_header
|
||||
|
||||
|
||||
class Test_pktRequirementsHeader(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.cnt = createContainer(structId=0)
|
||||
self.cnt = createRequirementsHeaderCnt(structId=0)
|
||||
|
||||
def test_validateCntId(self):
|
||||
self.assertEqual(3, self.cnt.cnt_id)
|
||||
|
||||
def test_getCntStructId(self):
|
||||
self.assertEqual(0, createContainer(structId=0).cnt_structure_id)
|
||||
self.assertEqual(1, createContainer(structId=1).cnt_structure_id)
|
||||
self.assertEqual(2, createContainer(structId=2).cnt_structure_id)
|
||||
self.assertEqual(0, createRequirementsHeaderCnt(structId=0).cnt_structure_id)
|
||||
self.assertEqual(1, createRequirementsHeaderCnt(structId=1).cnt_structure_id)
|
||||
self.assertEqual(2, createRequirementsHeaderCnt(structId=2).cnt_structure_id)
|
||||
|
||||
|
||||
class Test_pktRequirementsHeader_StructIdZero(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.cnt = createContainer(structId=0)
|
||||
self.cnt = createRequirementsHeaderCnt(structId=0)
|
||||
|
||||
def test_getCntFlags(self):
|
||||
self.assertEqual("<not available for version 0,1>", self.cnt.cnt_flags)
|
||||
|
|
@ -41,7 +40,7 @@ class Test_pktRequirementsHeader_StructIdZero(unittest.TestCase):
|
|||
self.assertEqual("<not available for version 0,1>", self.cnt.cnt_flags)
|
||||
|
||||
def test_FullBinary(self):
|
||||
self.assertEqual(DummyRequirementsHeader(structId=0).get_binary, self.cnt.cnt_full_binary)
|
||||
self.assertEqual(get_dummy_requirements_header(structId=0), self.cnt.cnt_full_binary)
|
||||
|
||||
def test_getOutput(self):
|
||||
self.assertEqual(('PckRequirementsHeader',
|
||||
|
|
@ -61,7 +60,7 @@ class Test_pktRequirementsHeader_StructIdZero(unittest.TestCase):
|
|||
|
||||
class Test_pktRequirementsHeader_StructIdOne(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.cnt = createContainer(structId=1)
|
||||
self.cnt = createRequirementsHeaderCnt(structId=1)
|
||||
|
||||
def test_getProgramName(self):
|
||||
self.assertEqual("abcdefghijklmnop", self.cnt.cnt_program_name)
|
||||
|
|
@ -79,7 +78,7 @@ class Test_pktRequirementsHeader_StructIdOne(unittest.TestCase):
|
|||
self.assertEqual("<not available for version 0,1>", self.cnt.cnt_flags)
|
||||
|
||||
def test_FullBinary(self):
|
||||
self.assertEqual(DummyRequirementsHeader(structId=1).get_binary, self.cnt.cnt_full_binary)
|
||||
self.assertEqual(get_dummy_requirements_header(structId=1), self.cnt.cnt_full_binary)
|
||||
|
||||
def test_getOutput(self):
|
||||
self.assertEqual(('PckRequirementsHeader',
|
||||
|
|
@ -99,7 +98,7 @@ class Test_pktRequirementsHeader_StructIdOne(unittest.TestCase):
|
|||
|
||||
class Test_pktRequirementsHeader_StructIdTwo(unittest.TestCase):
|
||||
def setUp(self) -> None:
|
||||
self.cnt = createContainer(structId=2)
|
||||
self.cnt = createRequirementsHeaderCnt(structId=2)
|
||||
|
||||
def test_getProgramName(self):
|
||||
self.assertEqual("abcdefghijklmnop", self.cnt.cnt_program_name)
|
||||
|
|
@ -117,7 +116,7 @@ class Test_pktRequirementsHeader_StructIdTwo(unittest.TestCase):
|
|||
self.assertEqual((0, 0, 0, 0), self.cnt.cnt_flags)
|
||||
|
||||
def test_FullBinary(self):
|
||||
self.assertEqual(DummyRequirementsHeader(structId=2).get_binary, self.cnt.cnt_full_binary)
|
||||
self.assertEqual(get_dummy_requirements_header(structId=2), self.cnt.cnt_full_binary)
|
||||
|
||||
def test_getOutput(self):
|
||||
self.assertEqual(('PckRequirementsHeader',
|
||||
|
|
@ -135,6 +134,5 @@ class Test_pktRequirementsHeader_StructIdTwo(unittest.TestCase):
|
|||
'Flags: (0, 0, 0, 0)']), self.cnt.output_cnt)
|
||||
|
||||
|
||||
def createContainer(structId):
|
||||
dummy_cnt = DummyRequirementsHeader(structId)
|
||||
return PckRequirementsHeader(dummy_cnt.get_binary, offset_in_pck=0)
|
||||
def createRequirementsHeaderCnt(structId):
|
||||
return PckRequirementsHeader(get_dummy_requirements_header(structId), offset_in_pck=0)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue