1

I need to test a method called addServerUrl() using the command "bin/test -t addServerUrl()" in terminal

addServerUrl contains the following code:


def addServerUrl(self,html_src,prefix):

    url = getToolByName(self.context, "portal_url")
    temp = html_src.replace('href="mailto:', '$XXX$')
    temp = temp.replace('href="', 'href="%s/%s' % (url, prefix))
    return  temp.replace('$XXX$', 'href="mailto:')

when run "bin/test -t addServerUrl()" in terminal i m getting the following error

File "/home/oomsys/brundelre3/src/bdr.theme/src/bdr/theme/browser/createPictMenu.py", line 159, in addServerUrl
url = getToolByName(self.context, "portal_url")()
File "<string>", line 10, in check_getToolByName
File "/home/oomsys/brundelre3/eggs/Products.CMFCore-2.2.7-py2.7.egg/Products/CMFCore/utils.py", line 120, in getToolByName
raise AttributeError, name
AttributeError: portal_url

Why am getting error in "url"??? Any one pls help soon.

1 Answer 1

0

first I created the test code like below

def test_addServerUrl(self):
    yyyy = xxxx(self.portal.REQUEST, self.portal)

Then i edited my code like below

def test_addServerUrl(self):
        request = self.portal.REQUEST
        yyyy= xxxx(self.portal, request)

Then it worked properly... My attribute error was solved....

Not the answer you're looking for? Browse other questions tagged .