Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
sbws
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
juga
sbws
Commits
4999ed64
Commit
4999ed64
authored
6 years ago
by
juga
Committed by
Matt Traudt
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Replace variables for results' fixtures
parent
f1b2d205
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/unit/lib/test_resultdump.py
+20
-41
20 additions, 41 deletions
tests/unit/lib/test_resultdump.py
with
20 additions
and
41 deletions
tests/unit/lib/test_resultdump.py
+
20
−
41
View file @
4999ed64
# -*- 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_IP_CHANGED
=
{
FP1
:
[
RESULTSUCCESS1
,
RESULTSUCCESS2
]}
RESULTDICT_IP_NOT_CHANGED
=
{
FP1
:
[
RESULTSUCCESS1
,
RESULTSUCCESS1
]}
def
test_trim_results_ip_changed_defaults
():
results_dict
=
trim_results_ip_changed
(
RESULTDICT_IP_NOT_CHANGED
)
assert
RESULTDICT_IP_NOT_CHANGED
==
results_dict
def
test_trim_results_ip_changed_on_changed_ipv4_changed
():
expected_results_dict
=
{
FP1
:
[
RESULTSUCCESS2
]}
results_dict
=
trim_results_ip_changed
(
RESULTDICT_IP_CHANGED
,
from
sbws.lib.resultdump
import
trim_results_ip_changed
def
test_trim_results_ip_changed_defaults
(
resultdict_ip_not_changed
):
results_dict
=
trim_results_ip_changed
(
resultdict_ip_not_changed
)
assert
resultdict_ip_not_changed
==
results_dict
def
test_trim_results_ip_changed_on_changed_ipv4_changed
(
resultdict_ip_changed
,
resultdict_ip_changed_trimmed
):
results_dict
=
trim_results_ip_changed
(
resultdict_ip_changed
,
on_changed_ipv4
=
True
)
assert
expected_
result
s_
dict
==
results_dict
assert
resultdict
_ip_changed_trimmed
==
results_dict
def
test_trim_results_ip_changed_on_changed_ipv4_no_changed
():
results_dict
=
trim_results_ip_changed
(
RESULTDICT_IP_NOT_CHANGED
,
def
test_trim_results_ip_changed_on_changed_ipv4_no_changed
(
resultdict_ip_not_changed
):
results_dict
=
trim_results_ip_changed
(
resultdict_ip_not_changed
,
on_changed_ipv4
=
True
)
assert
RESULTDICT_IP_NOT_CHANGED
==
results_dict
assert
resultdict_ip_not_changed
==
results_dict
def
test_trim_results_ip_changed_on_changed_ipv6
(
caplog
):
results_dict
=
trim_results_ip_changed
(
RESULTDICT_IP_NOT_CHANGED
,
def
test_trim_results_ip_changed_on_changed_ipv6
(
caplog
,
resultdict_ip_not_changed
):
results_dict
=
trim_results_ip_changed
(
resultdict_ip_not_changed
,
on_changed_ipv6
=
True
)
assert
RESULTDICT_IP_NOT_CHANGED
==
results_dict
assert
resultdict_ip_not_changed
==
results_dict
for
record
in
caplog
.
records
:
assert
record
.
levelname
==
'
WARNING
'
assert
'
Reseting bandwidth results when IPv6 changes,
'
\
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment