Exemple #1
0
    def testE_NoRedirection(self):
        print "\n\n########## Testing normal redirection works"
        url = '%s/ssl' % BASEURL
        api = dlsPhedexApi.DlsPhedexApi(url)

        res = api.getLocations(FakePhedexServer.BLOCK2)
        #        print 'RES:',res[0]
        self.assert_(len(res) == 1)
        self.assert_(len(res[0].locations) > 1)
Exemple #2
0
    def testC_InfiniteRedirection(self):
        print "\n\n########## Testing infinite redirection does not work"
        url = '%s/inf' % BASEURL
        api = dlsPhedexApi.DlsPhedexApi(url)

        try:
            res = api.getLocations(FakePhedexServer.BLOCK1)
            #            print 'RES:',res
            self.assert_(False)
        except DlsApiError as ex:
            self.assert_('infinite loop' in str(ex))
Exemple #3
0
    def testB_ChangingRedirection(self):
        print "\n\n########## Testing changing redirection does not work"
        url = '%s/change' % BASEURL
        api = dlsPhedexApi.DlsPhedexApi(url)

        try:
            res = api.getLocations(FakePhedexServer.BLOCK1)
            #            print 'RES:',res
            self.assert_(False)
        except DlsApiError as ex:
            self.assert_('trying to change' in str(ex))
Exemple #4
0
    def testF_DefaultUserAgent(self):
        print "\n\n########## Testing default user agent works"
        url = '%s/useragent' % BASEURL
        api = dlsPhedexApi.DlsPhedexApi(url)

        res = (api.getLocations(FakePhedexServer.BLOCK2))[0].fileBlock.name
        print 'RES:', res

        #       E.g.: 'dls-client/DLS_1_1_2 urllib2/2.6 Python/2.6.4 (CMS) Linux/2.6.18 (x86_64)
        self.C.basicPat = r'dls-client/[^ ]* urllib2/[^ ]* Python/[^ ]* '
        self.C.basicPat += '\(CMS\) Linux/[^ ]* \([^ ]*\)'
        pattern = re.compile(self.C.basicPat)
        self.assert_(pattern.match(res))
Exemple #5
0
    def testG_ExtendedUserAgent(self):
        print "\n\n########## Testing extended user agent works"
        url = '%s/useragent' % BASEURL
        api = dlsPhedexApi.DlsPhedexApi(
            url,
            uaFlexString='This is a test',
            uaClientsList=[['Tester', '1.1'], ['Sth', '2_4']],
        )

        res = (api.getLocations(FakePhedexServer.BLOCK2))[0].fileBlock.name
        print 'RES:', res

        extPat = r'This is a test, Sth/2_4 Tester/1.1 ' + self.C.basicPat
        pattern = re.compile(extPat)
        self.assert_(pattern.match(res))
Exemple #6
0
    def testD_GetRequest(self):
        print "\n\n########## Testing GET request (API creation check) works"
        url = '%s/normal' % BASEURL

        api = dlsPhedexApi.DlsPhedexApi(url, checkEndpoint=True)
        self.assert_(True)