Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Network Health
sbws
Commits
f6a0876e
Commit
f6a0876e
authored
Jun 18, 2018
by
juga
Browse files
Add test for trim_results_ip_changed
parent
4e7bc3e5
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/unit/lib/test_resultdump.py
0 → 100644
View file @
f6a0876e
# -*- coding: utf-8 -*-
"""Unit tests for resultdump."""
from
sbws.lib.resultdump
import
trim_results_ip_changed
,
Result
,
ResultSuccess
TIME1
=
1529232277.9028733
TIME2
=
1529232278.9028733
FP1
=
'A'
*
40
FP2
=
'Z'
*
40
ED25519
=
'g+Shk00y9Md0hg1S6ptnuc/wWKbADBgdjT0Kg+TSF3s'
CIRC
=
[
FP1
,
FP2
]
DEST_URL
=
'http://example.com/sbws.bin'
NICK
=
'A'
RELAY_ip1
=
'169.254.100.1'
RELAY_ip2
=
'169.254.100.2'
RELAY1
=
Result
.
Relay
(
FP1
,
NICK
,
RELAY_ip1
,
ED25519
)
RELAY2
=
Result
.
Relay
(
FP1
,
NICK
,
RELAY_ip2
,
ED25519
)
RTTS
=
[
5
,
25
]
DOWNLOADS
=
[{
'duration'
:
4
,
'amount'
:
40
}]
RESULTSUCCESS1
=
ResultSuccess
(
RTTS
,
DOWNLOADS
,
RELAY1
,
CIRC
,
DEST_URL
,
'sbws'
,
t
=
TIME1
)
RESULTSUCCESS2
=
ResultSuccess
(
RTTS
,
DOWNLOADS
,
RELAY2
,
CIRC
,
DEST_URL
,
'sbws'
,
t
=
TIME2
)
RESULTDICT
=
{
FP1
:
[
RESULTSUCCESS1
,
RESULTSUCCESS2
]}
def
test_trim_results_ip_changed
():
expected_results_dict
=
{
FP1
:
[
RESULTSUCCESS2
]}
results_dict
=
trim_results_ip_changed
(
RESULTDICT
)
assert
expected_results_dict
==
results_dict
Write
Preview
Supports
Markdown
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