コード例 #1
0
 def test_unpack_userparams_optional_with_default(self):
     """If an optional param is specified with a default value, and the
     param is not in the config, the value should be the default value.
     """
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(optional_thing="whatever")
     self.assertEqual(bc.optional_thing, "whatever")
コード例 #2
0
 def test_unpack_userparams_required(self):
     """Missing a required param should raise an error."""
     required = ["some_param"]
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(required)
     expected_value = self.mock_test_cls_configs.user_params["some_param"]
     self.assertEqual(bc.some_param, expected_value)
コード例 #3
0
 def test_unpack_userparams_default_overwrite_by_optional_param_list(self):
     """If an optional param is specified in kwargs, and the param is in the
     config, the value should be the one in the config.
     """
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(some_param="whatever")
     expected_value = self.mock_test_cls_configs.user_params["some_param"]
     self.assertEqual(bc.some_param, expected_value)
コード例 #4
0
 def test_unpack_userparams_required_missing(self):
     """Missing a required param should raise an error."""
     required = ["something"]
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     expected_msg = ("Missing required user param '%s' in test "
                     "configuration.") % required[0]
     with self.assertRaises(base_test.Error, msg=expected_msg):
         bc.unpack_userparams(required)
コード例 #5
0
 def test_unpack_userparams_default_overwrite(self):
     default_arg_val = "haha"
     actual_arg_val = "wawa"
     arg_name = "arg1"
     configs = self.mock_test_cls_configs.copy()
     configs.user_params[arg_name] = actual_arg_val
     bc = base_test.BaseTestClass(configs)
     bc.unpack_userparams(opt_param_names=[arg_name], arg1=default_arg_val)
     self.assertEqual(bc.arg1, actual_arg_val)
コード例 #6
0
 def test_unpack_userparams_optional(self):
     """If an optional param is specified, the value should be what's in the
     config.
     """
     opt = ["some_param"]
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(opt_param_names=opt)
     expected_value = self.mock_test_cls_configs.user_params["some_param"]
     self.assertEqual(bc.some_param, expected_value)
コード例 #7
0
ファイル: base_test_test.py プロジェクト: ragbansal/mobly
 def test_unpack_userparams_default_overwrite_by_required_param_list(self):
     """If an optional param is specified in kwargs, the param is in the
     required param list, and the param is not specified in the config, the
     param's alue should be the default value and there should be no error
     thrown.
     """
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(req_param_names=['a_kwarg_param'], a_kwarg_param="whatever")
     self.assertEqual(bc.a_kwarg_param, "whatever")
コード例 #8
0
 def test_unpack_userparams_basic(self):
     """Required and optional params are unpacked properly."""
     required = ["something"]
     optional = ["something_else"]
     configs = self.mock_test_cls_configs.copy()
     configs.user_params["something"] = 42
     configs.user_params["something_else"] = 53
     bc = base_test.BaseTestClass(configs)
     bc.unpack_userparams(
         req_param_names=required, opt_param_names=optional)
     self.assertEqual(bc.something, 42)
     self.assertEqual(bc.something_else, 53)
コード例 #9
0
 def test_unpack_userparams_default_None(self):
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(arg1="haha")
     self.assertEqual(bc.arg1, "haha")
コード例 #10
0
 def test_unpack_userparams_optional_missing(self):
     """Missing an optional param should not raise an error."""
     opt = ["something"]
     bc = base_test.BaseTestClass(self.mock_test_cls_configs)
     bc.unpack_userparams(opt_param_names=opt)