[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [ooni-probe/master] Improve test_deck unittest.



commit f9101d96b2d8b8295e79eaeb11dd14eb901d2915
Author: Arturo Filastò <arturo@xxxxxxxxxxx>
Date:   Fri Jan 13 16:16:28 2017 +0000

    Improve test_deck unittest.
    
    * Fix bug in creating options based on deck options
---
 ooni/deck/deck.py       | 4 +++-
 ooni/deck/legacy.py     | 5 ++++-
 ooni/tests/test_deck.py | 6 ++++--
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/ooni/deck/deck.py b/ooni/deck/deck.py
index 7e4faa4e..cb52bb22 100644
--- a/ooni/deck/deck.py
+++ b/ooni/deck/deck.py
@@ -37,12 +37,14 @@ def options_to_args(options):
     for k, v in options.items():
         if v is None:
             continue
-        if isinstance(v, bool):
+        if v == False:
             continue
         if (len(k)) == 1:
             args.append('-'+k)
         else:
             args.append('--'+k)
+        if v == True:
+            continue
         args.append(v)
     return args
 
diff --git a/ooni/deck/legacy.py b/ooni/deck/legacy.py
index 83e16a3a..4e9702e3 100644
--- a/ooni/deck/legacy.py
+++ b/ooni/deck/legacy.py
@@ -30,7 +30,10 @@ boolean_options = [
     'no-collector',
     'no-geoip',
     'no-yamloo',
-    'verbose'
+    'verbose',
+    'help',
+    'no-default-reporter',
+    'resume'
 ]
 
 def convert_legacy_deck(deck_data):
diff --git a/ooni/tests/test_deck.py b/ooni/tests/test_deck.py
index b2d05a65..1b8a3087 100644
--- a/ooni/tests/test_deck.py
+++ b/ooni/tests/test_deck.py
@@ -336,5 +336,7 @@ class TestNGDeck(ConfigTestCase):
             '/path/to/citizenlab-urls-global.txt')
 
     def test_options_to_args(self):
-        args = options_to_args({"f": "foobar.txt", "bar": None, "help": 0})
-        print(args)
+        args = options_to_args({"f": "foobar.txt", "bar": None,
+                                "disabled-flag": False, "enabled-flag": True})
+        self.assertEqual(set(args), set(['-f', 'foobar.txt',
+                                         '--enabled-flag']))



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits