def test_normalize(): """Assert the normalize function works properly.""" # TODO: more unit tests here. properties = {"a": Property(int), "b": Property(unicode)} eq_(normalize(properties, {"a": 1, "b": "foo"}), And(Condition("a", "=", 1), Condition("b", "=", "foo"))) properties = {"a": Property(float), "b": Property(unicode)} eq_(normalize(properties, {"a": 1, "b": "foo"}), And(Condition("a", "=", 1.0), Condition("b", "=", "foo"))) properties = {"a": Property(float), "b": Property(int)} normalize(properties, {"a": 1, "b": "foo"})
def item_from_xml(self, elem): """Build an item from an element representing an item. Subclasses may override this method according to their XML serialization mechanism. """ request_dict = dict(((child.tag, child.text) for child in elem)) if request_dict: request = normalize( self.remote_ap.properties, make_request(request_dict)) return (self.remote_ap.open(request),) else: return (None,)