How to use _create_params method in localstack

Best Python code snippet using localstack_python

api_test.py

Source:api_test.py Github

copy

Full Screen

...19 self._run_id = "dummy_run_id"20 self._min_nodes = 321 self._max_nodes = 622 self._kwargs: Dict[str, Any] = {}23 def _create_params(self) -> RendezvousParameters:24 return RendezvousParameters(25 backend=self._backend,26 endpoint=self._endpoint,27 run_id=self._run_id,28 min_nodes=self._min_nodes,29 max_nodes=self._max_nodes,30 **self._kwargs,31 )32 def test_init_initializes_params(self) -> None:33 self._kwargs["dummy_param"] = "x"34 params = self._create_params()35 self.assertEqual(params.backend, self._backend)36 self.assertEqual(params.endpoint, self._endpoint)37 self.assertEqual(params.run_id, self._run_id)38 self.assertEqual(params.min_nodes, self._min_nodes)39 self.assertEqual(params.max_nodes, self._max_nodes)40 self.assertEqual(params.get("dummy_param"), "x")41 def test_init_initializes_params_if_min_nodes_equals_to_1(self) -> None:42 self._min_nodes = 143 params = self._create_params()44 self.assertEqual(params.min_nodes, self._min_nodes)45 self.assertEqual(params.max_nodes, self._max_nodes)46 def test_init_initializes_params_if_min_and_max_nodes_are_equal(self) -> None:47 self._max_nodes = 348 params = self._create_params()49 self.assertEqual(params.min_nodes, self._min_nodes)50 self.assertEqual(params.max_nodes, self._max_nodes)51 def test_init_raises_error_if_backend_is_none_or_empty(self) -> None:52 for backend in [None, ""]:53 with self.subTest(backend=backend):54 self._backend = backend # type: ignore[assignment]55 with self.assertRaisesRegex(56 ValueError,57 r"^The rendezvous backend name must be a non-empty string.$",58 ):59 self._create_params()60 def test_init_raises_error_if_min_nodes_is_less_than_1(self) -> None:61 for min_nodes in [0, -1, -5]:62 with self.subTest(min_nodes=min_nodes):63 self._min_nodes = min_nodes64 with self.assertRaisesRegex(65 ValueError,66 rf"^The minimum number of rendezvous nodes \({min_nodes}\) must be greater "67 rf"than zero.$",68 ):69 self._create_params()70 def test_init_raises_error_if_max_nodes_is_less_than_min_nodes(self) -> None:71 for max_nodes in [2, 1, -2]:72 with self.subTest(max_nodes=max_nodes):73 self._max_nodes = max_nodes74 with self.assertRaisesRegex(75 ValueError,76 rf"^The maximum number of rendezvous nodes \({max_nodes}\) must be greater "77 "than or equal to the minimum number of rendezvous nodes "78 rf"\({self._min_nodes}\).$",79 ):80 self._create_params()81 def test_get_returns_none_if_key_does_not_exist(self) -> None:82 params = self._create_params()83 self.assertIsNone(params.get("dummy_param"))84 def test_get_returns_default_if_key_does_not_exist(self) -> None:85 params = self._create_params()86 self.assertEqual(params.get("dummy_param", default="x"), "x")87 def test_get_as_bool_returns_none_if_key_does_not_exist(self) -> None:88 params = self._create_params()89 self.assertIsNone(params.get_as_bool("dummy_param"))90 def test_get_as_bool_returns_default_if_key_does_not_exist(self) -> None:91 params = self._create_params()92 self.assertTrue(params.get_as_bool("dummy_param", default=True))93 def test_get_as_bool_returns_true_if_value_represents_true(self) -> None:94 for value in ["1", "True", "tRue", "T", "t", "yEs", "Y", 1, True]:95 with self.subTest(value=value):96 self._kwargs["dummy_param"] = value97 params = self._create_params()98 self.assertTrue(params.get_as_bool("dummy_param"))99 def test_get_as_bool_returns_false_if_value_represents_false(self) -> None:100 for value in ["0", "False", "faLse", "F", "f", "nO", "N", 0, False]:101 with self.subTest(value=value):102 self._kwargs["dummy_param"] = value103 params = self._create_params()104 self.assertFalse(params.get_as_bool("dummy_param"))105 def test_get_as_bool_raises_error_if_value_is_invalid(self) -> None:106 for value in ["01", "Flse", "Ture", "g", "4", "_", "truefalse", 2, -1]:107 with self.subTest(value=value):108 self._kwargs["dummy_param"] = value109 params = self._create_params()110 with self.assertRaisesRegex(111 ValueError,112 r"^The rendezvous configuration option 'dummy_param' does not represent a "113 r"valid boolean value.$",114 ):115 params.get_as_bool("dummy_param")116 def test_get_as_int_returns_none_if_key_does_not_exist(self) -> None:117 params = self._create_params()118 self.assertIsNone(params.get_as_int("dummy_param"))119 def test_get_as_int_returns_default_if_key_does_not_exist(self) -> None:120 params = self._create_params()121 self.assertEqual(params.get_as_int("dummy_param", default=5), 5)122 def test_get_as_int_returns_integer_if_value_represents_integer(self) -> None:123 for value in ["0", "-10", "5", " 4", "4 ", " 4 ", 0, -4, 3]:124 with self.subTest(value=value):125 self._kwargs["dummy_param"] = value126 params = self._create_params()127 self.assertEqual(params.get_as_int("dummy_param"), int(cast(SupportsInt, value)))128 def test_get_as_int_raises_error_if_value_is_invalid(self) -> None:129 for value in ["a", "0a", "3b", "abc"]:130 with self.subTest(value=value):131 self._kwargs["dummy_param"] = value132 params = self._create_params()133 with self.assertRaisesRegex(134 ValueError,135 r"^The rendezvous configuration option 'dummy_param' does not represent a "136 r"valid integer value.$",137 ):138 params.get_as_int("dummy_param")139class _DummyRendezvousHandler(RendezvousHandler):140 def __init__(self, params: RendezvousParameters) -> None:141 self.params = params142 def get_backend(self) -> str:143 return "dummy_backend"144 def next_rendezvous(self) -> Tuple[Store, int, int]:145 raise NotImplementedError()146 def is_closed(self) -> bool:...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful