Hi, i would like to know how i can access the dictionary returned from
a function in a controller (that acts as a url) from a turbogears unit
test. At the moment i am building a request and calling the function
in a unit test as follows:

# create request
req = _cphttptools.Request("127.0.0.1", 80, "localhost", "http")
req.path = "directory/files/lsass/24751"

# call the function
res = testutil.call_with_request(cherrypy.root.directory.files, req)

whatever path i enter, i get a 404 not found.

using create_request i usually call a path as follows:

testutil.create_request("/directory/files/lsass.exe/24751")


any help on how i can get to the dictionary returned by the finction?

thanks.


Here is an extract of the code:

class SubController(controllers.Controller):

    @turbogears.expose()
    def index(self, *args, **kwargs):
          ....

 
@turbogears.expose(template="processlibrary.templates.libraryitem")
    def files(self, *args):
          ....
        return dict(details=libObj, parsed=parsed)

this allows urls such as http://localhost:8080/directory/files/lsass/24751

in the test file:

class RootTest(controllers.RootController):
    directory = LibraryViewController()


class TestSubControllerTestCase(unittest.TestCase):
    """Test suite for LibraryView controller"""

    def setUp(self):
        cherrypy.root = RootTest()

    def tearDown(self):
        pass

    def test_files_alternatives(self):
        req = _cphttptools.Request("127.0.0.1", 80, "localhost",
"http")
        req.path = "directory/files/lsass/24751"
        res =
testutil.call_with_request(cherrypy.root.directory.files, req)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/turbogears?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to