def connection(cls):
     """A connection object which handles all HTTP requests."""
     super_class = cls.__mro__[1]
     if super_class == object or '_connection' in cls.__dict__:
         if cls._connection is None:
             cls._connection = connection.Connection(
                 cls.site, cls.user, cls.password, cls.timeout, cls.format)
         return cls._connection
     else:
         return super_class.connection
Exemplo n.º 2
0
    def setUp(self):
        '''Create test objects.'''
        matz = {'id': 1, 'name': 'Matz'}
        david = {'id': 2, 'name': 'David'}
        self.matz = util.to_xml(matz, root='person')
        self.david = util.to_xml(david, root='person')
        self.people = util.to_xml([matz, david], root='people')
        self.people_single = util.to_xml([matz], root='people-single-elements')
        self.people_empty = util.to_xml([], root='people-empty-elements')

        http_fake.initialize()
        self.http = http_fake.TestHandler
        self.http.site = 'http://localhost'
        self.http.set_response(Error('Bad request'))

        self.header = {'Key': 'value'}
        self.connection = connection.Connection(self.http.site)
Exemplo n.º 3
0
 def setUp(self):
     super(HTTPSConnectionTest, self).setUp()
     # Override the base site URL and re-create the connection.
     self.http.site = 'https://localhost'
     self.connection = connection.Connection(self.http.site)