def test_set_request_single_resource(self):
     # resourceID must be zero
     request = client.SetRequest()
     request.add((1, 2, 3), "VALUE")
     expectedXml = """
     <Request>
       <Type>Set</Type>
       <Content>
         <Objects>
           <Object>
             <ID>1</ID>
             <ObjectInstance>
               <ID>2</ID>
               <Resource>
                 <ID>3</ID>
                 <Value>VALUE</Value>
               </Resource>
             </ObjectInstance>
           </Object>
         </Objects>
       </Content>
     </Request>
     """
     #print(str(request._content._model))
     self.assertEqualXml(expectedXml, request.serialize())
 def test_set_request_multiple_objects(self):
     request = client.SetRequest()
     request.add((0, 0, 0), "VALUE1")
     request.add((1, 0, 0), "VALUE2")
     expectedXml = """
     <Request>
       <Type>Set</Type>
       <Content>
         <Objects>
           <Object>
             <ID>0</ID>
             <ObjectInstance>
               <ID>0</ID>
               <Resource>
                 <ID>0</ID>
                 <Value>VALUE1</Value>
               </Resource>
             </ObjectInstance>
           </Object>
           <Object>
             <ID>1</ID>
             <ObjectInstance>
               <ID>0</ID>
               <Resource>
                 <ID>0</ID>
                 <Value>VALUE2</Value>
               </Resource>
             </ObjectInstance>
           </Object>
         </Objects>
       </Content>
     </Request>
     """
     self.assertEqualXml(expectedXml, request.serialize())
 def test_set_request_resource_instance(self):
     request = client.SetRequest()
     request.add((1, 2, 3, 4), "VALUE")
     expectedXml = """
     <Request>
       <Type>Set</Type>
       <Content>
         <Objects>
           <Object>
             <ID>1</ID>
             <ObjectInstance>
               <ID>2</ID>
               <Resource>
                 <ID>3</ID>
                 <ResourceInstance>
                   <ID>4</ID>
                   <Value>VALUE</Value>
                 </ResourceInstance>
               </Resource>
             </ObjectInstance>
           </Object>
         </Objects>
       </Content>
     </Request>
     """
     self.assertEqualXml(expectedXml, request.serialize())
 def test_set_request_complex(self):
     request = client.SetRequest()
     request.add((7, 0, 0), "VALUE1")
     request.add((7, 0, 1), "VALUE2")
     request.add((7, 1, 0), "VALUE3")
     request.add((7, 1, 9, 0), "VALUE4")
     request.add((7, 8, 0), "VALUE5")
     expectedXml = """
     <Request>
       <Type>Set</Type>
       <Content>
         <Objects>
           <Object>
             <ID>7</ID>
             <ObjectInstance>
               <ID>0</ID>
               <Resource>
                 <ID>0</ID>
                 <Value>VALUE1</Value>
               </Resource>
               <Resource>
                 <ID>1</ID>
                 <Value>VALUE2</Value>
               </Resource>
             </ObjectInstance>
             <ObjectInstance>
               <ID>1</ID>
               <Resource>
                 <ID>0</ID>
                 <Value>VALUE3</Value>
               </Resource>
               <Resource>
                 <ID>9</ID>
                 <ResourceInstance>
                   <ID>0</ID>
                   <Value>VALUE4</Value>
                 </ResourceInstance>
               </Resource>
             </ObjectInstance>
             <ObjectInstance>
               <ID>8</ID>
               <Resource>
                 <ID>0</ID>
                 <Value>VALUE5</Value>
               </Resource>
             </ObjectInstance>
           </Object>
         </Objects>
       </Content>
     </Request>
     """
     self.assertEqualXml(expectedXml, request.serialize())
    def test_set_request_invalid_path(self):
        request = client.SetRequest()
        print request
        with self.assertRaises(ipc_core.IpcError) as cm:
            request.add((0, 0), "VALUE1")
        self.assertEqual("Unsupported path", cm.exception.message)

        with self.assertRaises(ipc_core.IpcError) as cm:
            request.add((0,), "VALUE2")
        self.assertEqual("Unsupported path", cm.exception.message)

        with self.assertRaises(ipc_core.IpcError) as cm:
            request.add(None, "VALUE3")
        self.assertEqual("Unsupported path", cm.exception.message)