Bug 1315704 - Test that BaseMarionetteArguments constructs arguments as expected; r=maja_zf
authorLeni Kadali <lenikmutungi@gmail.com>
Wed, 13 Dec 2017 12:59:09 +0300
changeset 396701 a83942bf8ddd9b291634953dedef8f23c6dfbdb8
parent 396700 81d9218d6b03d3e0c58fe3c3c16a6efcac86d896
child 396702 5eff2c0351a9b0dfb9717b6732f3c38259ea3967
push id98347
push usercsabou@mozilla.com
push dateMon, 18 Dec 2017 16:20:25 +0000
treeherdermozilla-inbound@5eff2c0351a9 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmaja_zf
bugs1315704
milestone59.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1315704 - Test that BaseMarionetteArguments constructs arguments as expected; r=maja_zf
testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_arguments.py
--- a/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_arguments.py
+++ b/testing/marionette/harness/marionette_harness/tests/harness_unit/test_marionette_arguments.py
@@ -1,15 +1,15 @@
 # This Source Code Form is subject to the terms of the Mozilla Public
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 import mozunit
 import pytest
 
-from marionette_harness.runtests import MarionetteArguments
+from marionette_harness.runtests import MarionetteArguments, MarionetteTestRunner
 
 
 @pytest.mark.parametrize("socket_timeout", ['A', '10', '1B-', '1C2', '44.35'])
 def test_parse_arg_socket_timeout(socket_timeout):
     argv = ['marionette', '--socket-timeout', socket_timeout]
     parser = MarionetteArguments()
 
     def _is_float_convertible(value):
@@ -23,10 +23,44 @@ def test_parse_arg_socket_timeout(socket
         with pytest.raises(SystemExit) as ex:
             parser.parse_args(args=argv)
         assert ex.value.code == 2
     else:
         args = parser.parse_args(args=argv)
         assert hasattr(args, 'socket_timeout') and args.socket_timeout == float(socket_timeout)
 
 
+@pytest.mark.parametrize("arg_name, arg_dest, arg_value, expected_value",
+                         [('app-arg', 'app_args', 'samplevalue', ['samplevalue']),
+                          ('symbols-path', 'symbols_path', 'samplevalue', 'samplevalue'),
+                          ('gecko-log', 'gecko_log', 'samplevalue', 'samplevalue'),
+                          ('app', 'app', 'samplevalue', 'samplevalue')])
+def test_parsing_optional_arguments(mach_parsed_kwargs, arg_name, arg_dest, arg_value,
+                                    expected_value):
+    parser = MarionetteArguments()
+    parsed_args = parser.parse_args(['--' + arg_name, arg_value])
+    result = vars(parsed_args)
+    assert result.get(arg_dest) == expected_value
+    mach_parsed_kwargs[arg_dest] = result[arg_dest]
+    runner = MarionetteTestRunner(**mach_parsed_kwargs)
+    built_kwargs = runner._build_kwargs()
+    assert built_kwargs[arg_dest] == expected_value
+
+
+@pytest.mark.parametrize("arg_name, arg_dest, arg_value, expected_value",
+                         [('adb', 'adb_path', 'samplevalue', 'samplevalue'),
+                          ('avd', 'avd', 'samplevalue', 'samplevalue'),
+                          ('avd-home', 'avd_home', 'samplevalue', 'samplevalue'),
+                          ('package', 'package_name', 'samplevalue', 'samplevalue')])
+def test_parse_opt_args_emulator(mach_parsed_kwargs, arg_name, arg_dest, arg_value, expected_value):
+    parser = MarionetteArguments()
+    parsed_args = parser.parse_args(['--' + arg_name, arg_value])
+    result = vars(parsed_args)
+    assert result.get(arg_dest) == expected_value
+    mach_parsed_kwargs[arg_dest] = result[arg_dest]
+    mach_parsed_kwargs["emulator"] = True
+    runner = MarionetteTestRunner(**mach_parsed_kwargs)
+    built_kwargs = runner._build_kwargs()
+    assert built_kwargs[arg_dest] == expected_value
+
+
 if __name__ == '__main__':
     mozunit.main('--log-tbpl=-')