def get_interfaces(self): # TODO: should use general import cache interfaces = [] for k, v in self.data.iteritems(): if '.' not in k: continue mod_name, class_name = k.rsplit('.', 1) interface = getattr(__import__(mod_name, {}, {}, [class_name]), class_name) interfaces.append(unserialize(interface, v)) return interfaces
def test_serialize_and_unserialize(self): http = Http('http://example.com/foo/', 'GET', {}, 'bar=baz') result = unserialize(Http, http.serialize()).serialize() self.assertTrue('url' in result, result) self.assertEquals(result['url'], 'http://example.com/foo/') self.assertTrue('method' in result, result) self.assertEquals(result['method'], 'GET') self.assertTrue('data' in result, result) self.assertEquals(result['data'], {}) self.assertTrue('querystring' in result, result) self.assertEquals(result['querystring'], 'bar=baz')
def test_unserialize(self): http = unserialize(Http, { 'url': 'http://example.com/foo/', 'method': 'GET', 'data': {}, 'querystring': 'bar=baz', }) self.assertEquals(http.url, 'http://example.com/foo/') self.assertEquals(http.method, 'GET') self.assertEquals(http.data, {}) self.assertEquals(http.querystring, 'bar=baz')
def test_unserialize(self): http = unserialize( Http, { 'url': 'http://example.com/foo/', 'method': 'GET', 'data': {}, 'querystring': 'bar=baz', }) self.assertEquals(http.url, 'http://example.com/foo/') self.assertEquals(http.method, 'GET') self.assertEquals(http.data, {}) self.assertEquals(http.querystring, 'bar=baz')
def test_serialize_unserialize_behavior(self): result = unserialize(type(self.interface), self.interface.serialize()) assert self.interface.serialize() == result.serialize()