def test_get_things_no_dates(self):
     c = self.get_dummy_health_vault_conn()
     THING1_KEY = "thing1key"
     THING2_KEY = "thing2key"
     DATATYPE = "DataType-Value"
     request_xml = "<info><group>" \
                     "<filter><type-id>{DATATYPE}</type-id></filter>" \
                     "<format><section>core</section><xml/></format>" \
                   "</group></info>".format(DATATYPE=DATATYPE)
     response_body = """
     <response>
         <x:info xmlns:x="urn:com.microsoft.wc.methods.response.GetThings">
             <get-things-does-not-parse-this/>
         </x:info>
     </response>
     """.format(DATATYPE=DATATYPE, THING1_KEY=THING1_KEY, THING2_KEY=THING2_KEY)
     expected_return_value = ET.fromstring(response_body).find("{urn:com.microsoft.wc.methods.response.GetThings}info")
     print "expected_return_value = %s" % elt_as_string(expected_return_value)
     self.validate_basr_method(
         c.get_things,
         (DATATYPE,), {},
         ('GetThings', request_xml), {},
         (None, response_body, ET.fromstring(response_body)),
         expected_return_value
     )
示例#2
0
 def test_get_things_no_dates(self):
     c = self.get_dummy_health_vault_conn()
     THING1_KEY = "thing1key"
     THING2_KEY = "thing2key"
     DATATYPE = "DataType-Value"
     request_xml = "<info><group>" \
                     "<filter><type-id>{DATATYPE}</type-id></filter>" \
                     "<format><section>core</section><xml/></format>" \
                   "</group></info>".format(DATATYPE=DATATYPE)
     response_body = """
     <response>
         <x:info xmlns:x="urn:com.microsoft.wc.methods.response.GetThings">
             <get-things-does-not-parse-this/>
         </x:info>
     </response>
     """.format(DATATYPE=DATATYPE,
                THING1_KEY=THING1_KEY,
                THING2_KEY=THING2_KEY)
     expected_return_value = ET.fromstring(response_body).find(
         "{urn:com.microsoft.wc.methods.response.GetThings}info")
     print "expected_return_value = %s" % elt_as_string(
         expected_return_value)
     self.validate_basr_method(
         c.get_things, (DATATYPE, ), {}, ('GetThings', request_xml), {},
         (None, response_body, ET.fromstring(response_body)),
         expected_return_value)
 def validate_basr_method(self, method, method_args, method_kwargs,
                          expected_basr_args, expected_basr_kwargs,
                          basr_return_value,
                          expected_return_value):
     """Test any HealthVaultConn method that calls _build_and_send_request and returns something
     """
     with mock.patch.object(HealthVaultConn, '_build_and_send_request') as basr:
         basr.return_value = basr_return_value
         method_return_value = method(*method_args, **method_kwargs)
         # For some reason, ElementTree objects don't compare equal even with the same content, so
         # for return values we need to support comparing them another way
         if isinstance(expected_return_value, ET.Element):
             self.assertEqual(elt_as_string(expected_return_value),
                              elt_as_string(method_return_value))
         else:
             self.assertEqual(expected_return_value, method_return_value)
         (args, kwargs) = basr.call_args
         self.assertEqual(expected_basr_args, args)
         self.assertEqual(expected_basr_kwargs, kwargs)
示例#4
0
 def validate_basr_method(self, method, method_args, method_kwargs,
                          expected_basr_args, expected_basr_kwargs,
                          basr_return_value, expected_return_value):
     """Test any HealthVaultConn method that calls _build_and_send_request and returns something
     """
     with mock.patch.object(HealthVaultConn,
                            '_build_and_send_request') as basr:
         basr.return_value = basr_return_value
         method_return_value = method(*method_args, **method_kwargs)
         # For some reason, ElementTree objects don't compare equal even with the same content, so
         # for return values we need to support comparing them another way
         if isinstance(expected_return_value, ET.Element):
             self.assertEqual(elt_as_string(expected_return_value),
                              elt_as_string(method_return_value))
         else:
             self.assertEqual(expected_return_value, method_return_value)
         (args, kwargs) = basr.call_args
         self.assertEqual(expected_basr_args, args)
         self.assertEqual(expected_basr_kwargs, kwargs)