[tor-commits] [sbws/master] fix: tests: Replace str by int

juga at torproject.org juga at torproject.org
Wed Mar 27 12:42:11 UTC 2019


commit 9b054bad2aba8ac1a32ab059a9725f875d799677
Author: juga0 <juga at riseup.net>
Date:   Wed Mar 27 06:15:29 2019 +0000

    fix: tests: Replace str by int
    
    when setting vote and unmeasured Keys.
    It doesn't matter here because there're not operations with the
    Keys and they're always converted to string in the bandwidth file,
    but it less confusing as integer.
---
 sbws/lib/v3bwfile.py            |  4 ++--
 tests/unit/lib/test_v3bwfile.py | 14 +++++++-------
 2 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index a4ce748..89c66eb 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -626,8 +626,8 @@ class V3BWLine(object):
         # reason.
         # This could be done in a better way as part of a refactor #28684.
 
-        kwargs['vote'] = '0'
-        kwargs['unmeasured'] = '1'
+        kwargs['vote'] = 0
+        kwargs['unmeasured'] = 1
 
         exclusion_reason = None
 
diff --git a/tests/unit/lib/test_v3bwfile.py b/tests/unit/lib/test_v3bwfile.py
index b84a6f4..720cd4b 100644
--- a/tests/unit/lib/test_v3bwfile.py
+++ b/tests/unit/lib/test_v3bwfile.py
@@ -267,8 +267,8 @@ def test_from_results_read(datadir, tmpdir, conf, args):
     expected_bwls = V3BWFile.bw_torflow_scale(raw_bwls)
     # Since the scaled lines will be less than the 60% relays in the network,
     # set under_min_report.
-    expected_bwls[0].under_min_report = '1'
-    expected_bwls[0].vote = '0'
+    expected_bwls[0].under_min_report = 1
+    expected_bwls[0].vote = 0
     expected_f = V3BWFile(expected_header, expected_bwls)
     # This way is going to convert bw to KB
     v3bwfile = V3BWFile.from_results(results)
@@ -369,8 +369,8 @@ def test_results_away_each_other(datadir):
     bwl, reason = V3BWLine.from_results(values, secs_away=secs_away, min_num=2)
     assert bwl.relay_recent_measurements_excluded_near_count == 2
     assert reason == 'recent_measurements_excluded_near_count'
-    assert bwl.vote == '0'
-    assert bwl.unmeasured == '1'
+    assert bwl.vote == 0
+    assert bwl.unmeasured == 1
 
     success_results = [r for r in values if isinstance(r, ResultSuccess)]
     assert len(success_results) >= min_num
@@ -391,8 +391,8 @@ def test_results_away_each_other(datadir):
     bwl, reason = V3BWLine.from_results(values, min_num=2)
     assert bwl.relay_recent_measurements_excluded_few_count == 1
     assert reason == 'recent_measurements_excluded_few_count'
-    assert bwl.vote == '0'
-    assert bwl.unmeasured == '1'
+    assert bwl.vote == 0
+    assert bwl.unmeasured == 1
 
     success_results = [r for r in values if isinstance(r, ResultSuccess)]
     assert len(success_results) < min_num
@@ -498,7 +498,7 @@ def test_set_under_min_report(mock_consensus, conf, datadir):
     bwl = v3bwfile.bw_lines[0]
     assert bwl.vote == 0
     assert bwl.under_min_report == 1
-    assert bwl.unmeasured == '1'
+    assert bwl.unmeasured == 1
     assert bwl.bw == 1
 
     # The number of relays after scaling is than the 60% in the network,



More information about the tor-commits mailing list