commit 91d9e90f099ff94e18d350697e8872a4ab0c61cc Author: juga0 juga@riseup.net Date: Tue Jun 19 20:09:51 2018 +0000
Improve tests for reseting bw on IP changes --- tests/unit/lib/test_resultdump.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-)
diff --git a/tests/unit/lib/test_resultdump.py b/tests/unit/lib/test_resultdump.py index 05a21ae..26794cb 100644 --- a/tests/unit/lib/test_resultdump.py +++ b/tests/unit/lib/test_resultdump.py @@ -11,10 +11,10 @@ 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) +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}]
@@ -22,10 +22,16 @@ 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]} +RESULTDICT_IP_CHANGED = {FP1: [RESULTSUCCESS1, RESULTSUCCESS2]} +RESULTDICT_IP_NOT_CHANGED = {FP1: [RESULTSUCCESS1, RESULTSUCCESS1]}
def test_trim_results_ip_changed(): expected_results_dict = {FP1: [RESULTSUCCESS2]} - results_dict = trim_results_ip_changed(RESULTDICT) + results_dict = trim_results_ip_changed(RESULTDICT_IP_CHANGED) assert expected_results_dict == results_dict + + +def test_trim_results_ip_changed_false(): + results_dict = trim_results_ip_changed(RESULTDICT_IP_CHANGED) + assert RESULTDICT_IP_NOT_CHANGED == results_dict