Commit 944d9436 authored by Lukas Baca's avatar Lukas Baca
Browse files

44 tests for common

parent 2bd7acbb
from common import *
DTN_TIME = 606658292
UNIX_TIME = 1553343092
def test_time_conversion():
assert unix2dtn(UNIX_TIME) == DTN_TIME
assert dtn2unix(DTN_TIME) == UNIX_TIME
DATA = 1023
ENCODED_DATA = b'\x87\x7f'
def test_encode():
assert sdnv_encode(DATA) == ENCODED_DATA
DATA_READ = [ 0x12, 0x11, 0x10, 0x09];
def test_read():
assert sdnv_read(DATA_READ,2) == (16, 3)
SERIAL_RESPONSE =b'\x9f\x89\x07\x00\x01\x82\x01etest2\x82\x01dtest\x82\x01\x00\x82\x1a$(\xde\xf4\x00\x19\x01,B%r\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00D]}\xd8u\x87\x08\x02\x00\x02\x01\x00D\x98\x9d\x838\x87\x01\x00\x00\x02\x02aHDF\xa27\x80\xff'
SERIAL_TCPCL_RESPONSE = b'\x13M\x9f\x89\x07\x00\x01\x82\x01etest2\x82\x01dtest\x82\x01\x00\x82\x1a$(\xde\xf4\x00\x19\x01,B%r\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00D]}\xd8u\x87\x08\x02\x00\x02\x01\x00D\x98\x9d\x838\x87\x01\x00\x00\x02\x02aHDF\xa27\x80\xff'
def test_serialize():
bundle = serialize_bundle(
"dtn:test",
"dtn:test2",
"H",
NULL_EID,
UNIX_TIME
)
assert bundle == SERIAL_RESPONSE
result = serialize_tcpcl_single_bundle_segment(bundle)
assert result == SERIAL_TCPCL_RESPONSE
START_OFFSET = 4572
END_OFFSET = 12512
CONTACT = (606671843, 606679783, 500)
SERIAL_UPCN_CONFIG_RESPONSE = b'1(dtn:pyDTN-2.dtn):(172.25.0.12:2002)::[{606671843,606679783,500}];'
def test_serialize_config():
result = serialize_upcn_config_message(
"dtn:pyDTN-2.dtn",
"172.25.0.12:2002",
contacts=[
CONTACT,
],
)
assert result == SERIAL_UPCN_CONFIG_RESPONSE
import sys
sys.path.insert(0, '../ipdtn')
import common
DTN_TIME = 606658292
UNIX_TIME = 1553343092
# content of test_sample.py
def test_time():
assert common.unix2dtn(UNIX_TIME) == DTN_TIME
assert common.dtn2unix(DTN_TIME) == UNIX_TIME
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment