Exemplo n.º 1
0
 def test_with_id_provider_booked_ids(self):
     context_element = etree.fromstring('<context id="a"/>')
     provider = IdProvider(context_element)
     provider.book_ids("a-instance_attributes", "a-instance_attributes-1-a")
     nvpair.append_new_nvset(
         "instance_attributes",
         context_element,
         {
             "a": "b",
             "c": "d",
         },
         provider,
     )
     assert_xml_equal(
         """
             <context id="a">
                 <instance_attributes id="a-instance_attributes-1">
                     <nvpair
                         id="a-instance_attributes-1-a-1" name="a" value="b"
                     />
                     <nvpair
                         id="a-instance_attributes-1-c" name="c" value="d"
                     />
                 </instance_attributes>
             </context>
         """,
         etree_to_str(context_element),
     )
Exemplo n.º 2
0
 def test_append_new_nvset_to_given_element(self):
     context_element = etree.fromstring('<context id="a"/>')
     id_provider = IdProvider(context_element)
     nvpair.append_new_nvset(
         "instance_attributes",
         context_element,
         {
             "a": "b",
             "c": "d",
         },
         id_provider,
     )
     assert_xml_equal(
         """
             <context id="a">
                 <instance_attributes id="a-instance_attributes">
                     <nvpair
                         id="a-instance_attributes-a" name="a" value="b"
                     />
                     <nvpair
                         id="a-instance_attributes-c" name="c" value="d"
                     />
                 </instance_attributes>
             </context>
         """,
         etree_to_str(context_element),
     )
Exemplo n.º 3
0
 def test_with_id_provider_booked_ids(self):
     context_element = etree.fromstring('<context id="a"/>')
     provider = IdProvider(context_element)
     provider.book_ids("a-instance_attributes", "a-instance_attributes-1-a")
     nvpair.append_new_nvset(
         "instance_attributes",
         context_element,
         {
             "a": "b",
             "c": "d",
         },
         provider
     )
     assert_xml_equal(
         """
             <context id="a">
                 <instance_attributes id="a-instance_attributes-1">
                     <nvpair
                         id="a-instance_attributes-1-a-1" name="a" value="b"
                     />
                     <nvpair
                         id="a-instance_attributes-1-c" name="c" value="d"
                     />
                 </instance_attributes>
             </context>
         """,
         etree_to_str(context_element)
     )
Exemplo n.º 4
0
 def test_append_new_nvset_to_given_element(self):
     context_element = etree.fromstring('<context id="a"/>')
     id_provider = IdProvider(context_element)
     nvpair.append_new_nvset(
         "instance_attributes",
         context_element,
         {
             "a": "b",
             "c": "d",
         },
         id_provider
     )
     assert_xml_equal(
         """
             <context id="a">
                 <instance_attributes id="a-instance_attributes">
                     <nvpair
                         id="a-instance_attributes-a" name="a" value="b"
                     />
                     <nvpair
                         id="a-instance_attributes-c" name="c" value="d"
                     />
                 </instance_attributes>
             </context>
         """,
         etree_to_str(context_element)
     )
Exemplo n.º 5
0
 def test_append_new_nvset_to_given_element(self):
     context_element = etree.fromstring('<context id="a"/>')
     nvpair.append_new_nvset("instance_attributes", context_element, {
         "a": "b",
         "c": "d",
     })
     assert_xml_equal(etree.tostring(context_element).decode(), """
         <context id="a">
             <instance_attributes id="a-instance_attributes">
                 <nvpair id="a-instance_attributes-a" name="a" value="b"/>
                 <nvpair id="a-instance_attributes-c" name="c" value="d"/>
             </instance_attributes>
         </context>
     """)