Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
space-public
pyDTN
Commits
398b1c03
Commit
398b1c03
authored
Mar 24, 2019
by
Lukas Baca
1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
44 add tests to class
parent
944d9436
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
29 additions
and
29 deletions
+29
-29
tests/common_unit.py
tests/common_unit.py
+29
-29
No files found.
tests/common_unit.py
View file @
398b1c03
from
common
import
*
DTN_TIME
=
606658292
UNIX_TIME
=
1553343092
class
TestCommon
(
object
):
def
test_time_conversion
():
assert
unix2dtn
(
UNIX_TIME
)
==
DTN_TIME
assert
dtn2unix
(
DTN_TIME
)
==
UNIX_TIME
DTN_TIME
=
606658292
UNIX_TIME
=
1553343092
DATA
=
1023
ENCODED_DATA
=
b
'
\x87\x7f
'
def
test_time_conversion
(
self
):
assert
unix2dtn
(
self
.
UNIX_TIME
)
==
self
.
DTN_TIME
assert
dtn2unix
(
self
.
DTN_TIME
)
==
self
.
UNIX_TIME
def
test_encode
():
DATA
=
1023
ENCODED_DATA
=
b
'
\x87\x7f
'
assert
sdnv_encode
(
DATA
)
==
ENCODED_DATA
def
test_encode
(
self
):
assert
sdnv_encode
(
self
.
DATA
)
==
self
.
ENCODED_DATA
DATA_READ
=
[
0x12
,
0x11
,
0x10
,
0x09
];
DATA_READ
=
[
0x12
,
0x11
,
0x10
,
0x09
];
def
test_read
():
assert
sdnv_read
(
DATA_READ
,
2
)
==
(
16
,
3
)
def
test_read
(
self
):
assert
sdnv_read
(
self
.
DATA_READ
,
2
)
==
(
16
,
3
)
SERIAL_RESPONSE
=
b
'
\x9f\x89\x07\x00\x01\x82\x01
etest2
\x82\x01
dtest
\x82\x01\x00\x82\x1a
$(
\xde\xf4\x00\x19\x01
,B%r
\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00
D]}
\xd8
u
\x87\x08\x02\x00\x02\x01\x00
D
\x98\x9d\x83
8
\x87\x01\x00\x00\x02\x02
aHDF
\xa2
7
\x80\xff
'
SERIAL_TCPCL_RESPONSE
=
b
'
\x13
M
\x9f\x89\x07\x00\x01\x82\x01
etest2
\x82\x01
dtest
\x82\x01\x00\x82\x1a
$(
\xde\xf4\x00\x19\x01
,B%r
\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00
D]}
\xd8
u
\x87\x08\x02\x00\x02\x01\x00
D
\x98\x9d\x83
8
\x87\x01\x00\x00\x02\x02
aHDF
\xa2
7
\x80\xff
'
SERIAL_RESPONSE
=
b
'
\x9f\x89\x07\x00\x01\x82\x01
etest2
\x82\x01
dtest
\x82\x01\x00\x82\x1a
$(
\xde\xf4\x00\x19\x01
,B%r
\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00
D]}
\xd8
u
\x87\x08\x02\x00\x02\x01\x00
D
\x98\x9d\x83
8
\x87\x01\x00\x00\x02\x02
aHDF
\xa2
7
\x80\xff
'
SERIAL_TCPCL_RESPONSE
=
b
'
\x13
M
\x9f\x89\x07\x00\x01\x82\x01
etest2
\x82\x01
dtest
\x82\x01\x00\x82\x1a
$(
\xde\xf4\x00\x19\x01
,B%r
\x87\t\x01\x00\x02\x04\x82\x18\x1e\x00
D]}
\xd8
u
\x87\x08\x02\x00\x02\x01\x00
D
\x98\x9d\x83
8
\x87\x01\x00\x00\x02\x02
aHDF
\xa2
7
\x80\xff
'
def
test_serialize
():
bundle
=
serialize_bundle
(
def
test_serialize
(
self
):
bundle
=
serialize_bundle
(
"dtn:test"
,
"dtn:test2"
,
"H"
,
NULL_EID
,
UNIX_TIME
self
.
UNIX_TIME
)
assert
bundle
==
SERIAL_RESPONSE
result
=
serialize_tcpcl_single_bundle_segment
(
bundle
)
assert
result
==
SERIAL_TCPCL_RESPONSE
assert
bundle
==
self
.
SERIAL_RESPONSE
result
=
serialize_tcpcl_single_bundle_segment
(
bundle
)
assert
result
==
self
.
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}];'
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
(
def
test_serialize_config
(
self
):
result
=
serialize_upcn_config_message
(
"dtn:pyDTN-2.dtn"
,
"172.25.0.12:2002"
,
contacts
=
[
CONTACT
,
self
.
CONTACT
,
],
)
assert
result
==
SERIAL_UPCN_CONFIG_RESPONSE
assert
result
==
self
.
SERIAL_UPCN_CONFIG_RESPONSE
Boris Pilka
@boris.pilka
mentioned in commit
c9854d35
·
Mar 24, 2019
mentioned in commit
c9854d35
mentioned in commit c9854d35190b662328dd3ecb301990cfd7cd2952
Toggle commit list
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment