Ejemplo n.º 1
0
 def test_write_request_simple(self):
     request = server.WriteRequest()
     request.add(("TestClient1", (1, 2, 3, 4)), "VALUE0")
     expectedXml = """
     <Request>
       <Type>Write</Type>
       <Content>
         <Clients>
           <Client>
             <ID>TestClient1</ID>
             <Objects>
               <Object>
                 <ID>1</ID>
                 <ObjectInstance>
                   <ID>2</ID>
                   <Resource>
                     <ID>3</ID>
                     <ResourceInstance>
                       <ID>4</ID>
                       <Value>VALUE0</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
               </Object>
             </Objects>
           </Client>
         </Clients>
       </Content>
     </Request>
     """
     self.assertEqualXml(expectedXml, request.serialize())
Ejemplo n.º 2
0
 def test_write_request_multiple_objects(self):
     request = server.WriteRequest()
     request.add(("TestClient1", (1, 0, 3, 0)), "VALUE0")
     request.add(("TestClient1", (2, 7, 4, 1)), "VALUE1")
     request.add(("TestClient1", (10, 8, 17, 2)), "VALUE2")
     expectedXml = """
     <Request>
       <Type>Write</Type>
       <Content>
         <Clients>
           <Client>
             <ID>TestClient1</ID>
             <Objects>
               <Object>
                 <ID>1</ID>
                 <ObjectInstance>
                   <ID>0</ID>
                   <Resource>
                     <ID>3</ID>
                     <ResourceInstance>
                       <ID>0</ID>
                       <Value>VALUE0</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
               </Object>
               <Object>
                 <ID>2</ID>
                 <ObjectInstance>
                   <ID>7</ID>
                   <Resource>
                     <ID>4</ID>
                     <ResourceInstance>
                       <ID>1</ID>
                       <Value>VALUE1</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
               </Object>
               <Object>
                 <ID>10</ID>
                 <ObjectInstance>
                   <ID>8</ID>
                   <Resource>
                     <ID>17</ID>
                     <ResourceInstance>
                       <ID>2</ID>
                       <Value>VALUE2</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
               </Object>
             </Objects>
           </Client>
         </Clients>
       </Content>
     </Request>
     """
     self.assertEqualXml(expectedXml, request.serialize())
Ejemplo n.º 3
0
 def test_write_request_complex(self):
     request = server.WriteRequest()
     request.add(("TestClient1", (10, 20, 30, 40)), "VALUE0")
     request.add(("TestClient1", (10, 20, 30, 41)), "VALUE1")
     request.add(("TestClient1", (10, 20, 31, 40)), "VALUE2")
     request.add(("TestClient1", (10, 20, 31, 41)), "VALUE3")
     request.add(("TestClient1", (10, 20, 31, 42)), "VALUE4")
     request.add(("TestClient1", (10, 21, 30, 40)), "VALUE5")
     request.add(("TestClient1", (10, 21, 31, 40)), "VALUE6")
     request.add(("TestClient1", (10, 21, 31, 41)), "VALUE7")
     request.add(("TestClient1", (11, 20, 30, 40)), "VALUE8")
     request.add(("TestClient1", (11, 20, 30, 41)), "VALUE9")
     request.add(("TestClient1", (11, 21, 30, 40)), "VALUE10")
     request.add(("TestClient1", (11, 21, 31, 40)), "VALUE11")
     request.add(("TestClient1", (11, 21, 31, 41)), "VALUE12")
     expectedXml = """
     <Request>
       <Type>Write</Type>
       <Content>
         <Clients>
           <Client>
             <ID>TestClient1</ID>
             <Objects>
               <Object>
                 <ID>10</ID>
                 <ObjectInstance>
                   <ID>20</ID>
                   <Resource>
                     <ID>30</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE0</Value>
                     </ResourceInstance>
                     <ResourceInstance>
                       <ID>41</ID>
                       <Value>VALUE1</Value>
                     </ResourceInstance>
                   </Resource>
                   <Resource>
                     <ID>31</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE2</Value>
                     </ResourceInstance>
                     <ResourceInstance>
                       <ID>41</ID>
                       <Value>VALUE3</Value>
                     </ResourceInstance>
                     <ResourceInstance>
                       <ID>42</ID>
                       <Value>VALUE4</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
                 <ObjectInstance>
                   <ID>21</ID>
                   <Resource>
                     <ID>30</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE5</Value>
                     </ResourceInstance>
                   </Resource>
                   <Resource>
                     <ID>31</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE6</Value>
                     </ResourceInstance>
                     <ResourceInstance>
                       <ID>41</ID>
                       <Value>VALUE7</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
               </Object>
               <Object>
                 <ID>11</ID>
                 <ObjectInstance>
                   <ID>20</ID>
                   <Resource>
                     <ID>30</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE8</Value>
                     </ResourceInstance>
                     <ResourceInstance>
                       <ID>41</ID>
                       <Value>VALUE9</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
                 <ObjectInstance>
                   <ID>21</ID>
                   <Resource>
                     <ID>30</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE10</Value>
                     </ResourceInstance>
                   </Resource>
                   <Resource>
                     <ID>31</ID>
                     <ResourceInstance>
                       <ID>40</ID>
                       <Value>VALUE11</Value>
                     </ResourceInstance>
                     <ResourceInstance>
                       <ID>41</ID>
                       <Value>VALUE12</Value>
                     </ResourceInstance>
                   </Resource>
                 </ObjectInstance>
               </Object>
             </Objects>
           </Client>
         </Clients>
       </Content>
     </Request>
     """
     self.assertEqualXml(expectedXml, request.serialize())