Ejemplo n.º 1
0
 def test_run_iters_global_iterators(self):
     """Tests _replace_iter by modifying _iterators global object."""
     u = str(uuid.uuid4()).replace("-", "")
     _iterators[u] = get_fake_generator()
     _str = "/v1/{0}/test".format(u)
     res = rhm._run_iters(_str, action_field)
     self.assertEqual("/v1/{0}/test".format(0), res)
Ejemplo n.º 2
0
 def test_run_iters_dict_w_multiple_list(self):
     """Tests RHM._run_iters() w/ dict containing 2 lists."""
     _dict = {
         "a": ["ACTION_FIELD:var", "var2", "var3", ["ACTION_FIELD:var4"]]
     }
     res = rhm._run_iters(_dict, action_field)
     self.assertEqual(["var", "var2", "var3", ["var4"]], res.get("a"))
Ejemplo n.º 3
0
 def test_run_iters_global_iterators(self):
     """Tests _replace_iter by modifying _iterators global object."""
     u = str(uuid.uuid4()).replace("-", "")
     _iterators[u] = get_fake_generator()
     _str = "/v1/{0}/test".format(u)
     res = rhm._run_iters(_str, action_field)
     self.assertEqual("/v1/{0}/test".format(0), res)
Ejemplo n.º 4
0
 def test_run_iters_dict_w_multiple_list(self):
     """Tests RHM._run_iters() w/ dict containing 2 lists."""
     _dict = {
         "a": ["ACTION_FIELD:var", "var2", "var3", ["ACTION_FIELD:var4"]]
     }
     res = rhm._run_iters(_dict, action_field)
     self.assertEqual(["var", "var2", "var3", ["var4"]], res.get("a"))
Ejemplo n.º 5
0
 def test_run_iters_xml(self):
     """Tests RHM._run_iters() w/ dict containing 2 lists."""
     root = ElementTree.Element("root")
     a = ElementTree.Element("a")
     a.attrib = {"ACTION_FIELD:attrib": "val"}
     a.text = "ACTION_FIELD:var"
     root.append(a)
     res = rhm._run_iters(root, action_field)
     res_text = ElementTree.tostring(res)
     if not six.PY2:
         res_text = res_text.decode("utf-8")
     self.assertEqual('<root><a attrib="val">var</a></root>', res_text)
Ejemplo n.º 6
0
 def test_run_iters_xml(self):
     """Tests RHM._run_iters() w/ dict containing 2 lists."""
     root = ElementTree.Element("root")
     a = ElementTree.Element("a")
     a.attrib = {"ACTION_FIELD:attrib": "val"}
     a.text = "ACTION_FIELD:var"
     root.append(a)
     res = rhm._run_iters(root, action_field)
     res_text = ElementTree.tostring(res)
     if not six.PY2:
         res_text = res_text.decode("utf-8")
     self.assertEqual('<root><a attrib="val">var</a></root>', res_text)
Ejemplo n.º 7
0
 def test_run_iters_dict_w_list_w_dict(self):
     """Tests RHM._run_iters() w/ dict w/ a list containing a dict."""
     _dict = {"a": [{"ACTION_FIELD:b": "c"}]}
     res = rhm._run_iters(_dict, action_field)
     self.assertEqual({"b": "c"}, res.get("a")[0])
Ejemplo n.º 8
0
 def test_run_iters_dict_w_list_w_dict(self):
     """Tests RHM._run_iters() w/ dict w/ a list containing a dict."""
     _dict = {"a": [{"ACTION_FIELD:b": "c"}]}
     res = rhm._run_iters(_dict, action_field)
     self.assertEqual({"b": "c"}, res.get("a")[0])