Ejemplo n.º 1
0
    def test_root_element_to_json(self):
        # Test when element must be list:
        exp = ([{'flavor': {'links': [], 'value': {'value': '5'}}}], None)
        self.assertEqual(exp, xml.root_element_to_json("accounts", self.ROOT))

        # Test when element must not be list:
        exp = {'instance': {'flavor': {'links': [], 'value': {'value': '5'}}}}
        self.assertEqual((exp, None),
                         xml.root_element_to_json("not_in_list", self.ROOT))

        # Test rootEnabled:
        self.assertEqual((True, None),
                         xml.root_element_to_json("rootEnabled", self.ROOT))
Ejemplo n.º 2
0
    def test_root_element_to_json(self):
        # Test when element must be list:
        exp = ([{'flavor': {'links': [], 'value': {'value': '5'}}}], None)
        self.assertEqual(exp, xml.root_element_to_json("accounts", self.ROOT))

        # Test when element must not be list:
        exp = {'instance': {'flavor': {'links': [], 'value': {'value': '5'}}}}
        self.assertEqual((exp, None),
                         xml.root_element_to_json("not_in_list", self.ROOT))

        # Test rootEnabled True:
        t_element = etree.fromstring('''<rootEnabled> True </rootEnabled>''')
        self.assertEqual((True, None),
                         xml.root_element_to_json("rootEnabled", t_element))

        # Test rootEnabled False:
        f_element = etree.fromstring('''<rootEnabled> False </rootEnabled>''')
        self.assertEqual((False, None),
                         xml.root_element_to_json("rootEnabled", f_element))
Ejemplo n.º 3
0
    def test_root_element_to_json(self):
        # Test when element must be list:
        exp = ([{'flavor': {'links': [], 'value': {'value': '5'}}}], None)
        self.assertEqual(exp, xml.root_element_to_json("accounts", self.ROOT))

        # Test when element must not be list:
        exp = {'instance': {'flavor': {'links': [], 'value': {'value': '5'}}}}
        self.assertEqual((exp, None),
                         xml.root_element_to_json("not_in_list", self.ROOT))

        # Test rootEnabled True:
        t_element = etree.fromstring('''<rootEnabled> True </rootEnabled>''')
        self.assertEqual((True, None),
                         xml.root_element_to_json("rootEnabled", t_element))

        # Test rootEnabled False:
        f_element = etree.fromstring('''<rootEnabled> False </rootEnabled>''')
        self.assertEqual((False, None),
                         xml.root_element_to_json("rootEnabled", f_element))