Example #1
0
 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
Example #2
0
 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')
Example #3
0
 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')
Example #4
0
 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')
Example #5
0
 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')
Example #6
0
    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
Example #7
0
 def test_serialize_unserialize_behavior(self):
     result = unserialize(type(self.interface), self.interface.serialize())
     assert self.interface.serialize() == result.serialize()
Example #8
0
File: tests.py Project: 755/sentry
 def test_serialize_unserialize_behavior(self):
     result = unserialize(type(self.interface), self.interface.serialize())
     assert self.interface.serialize() == result.serialize()