Exemplo n.º 1
0
 def initialize(self):
     self.config = DefaultConfig()
     self.config.UnitTests.templates = getWMBASE() + '/src/templates/WMCore/WebTools'
     self.config.Webtools.section_('server')
     self.config.Webtools.server.socket_timeout = 1
     self.urlbase = self.config.getServerUrl()
     self.cache_path = tempfile.mkdtemp()
Exemplo n.º 2
0
class testRepeatCalls(RESTBaseUnitTest):
    def initialize(self):
        self.config = DefaultConfig()
        self.config.UnitTests.templates = getWMBASE() + '/src/templates/WMCore/WebTools'
        self.config.Webtools.section_('server')
        self.config.Webtools.server.socket_timeout = 1
        self.urlbase = self.config.getServerUrl()
        self.cache_path = tempfile.mkdtemp()

    def tearDown(self):
        shutil.rmtree(self.cache_path, ignore_errors = True)

    def test10Calls(self):
        fail_count = 0
        req = Requests.Requests(self.urlbase, {'req_cache_path': self.cache_path})

        for i in range(0, 5):
            time.sleep(i)
            print 'test %s starting at %s' % (i, time.time())
            try:
                result = req.get('/', incoming_headers={'Cache-Control':'no-cache'})
                self.assertEqual(False, result[3])
                self.assertEqual(200, result[1])
            except HTTPException, he:
                print 'test %s raised a %s error' % (i, he.status)
                fail_count += 1
            except Exception, e:
                print 'test %s raised an unexpected exception of type %s' % (i,type(e))
                print e
                fail_count += 1