예제 #1
0
파일: test_core.py 프로젝트: devdave/txWeb
def test_site_routeRequest_HandlesDirectoryListing():

    staticDir = Site(RootWithStaticDirectory())
    request = TestRequest([], "/files/")

    action = staticDir.routeRequest(request)
    response = action.render(request)
    assert isinstance(action, DirectoryLister)
예제 #2
0
파일: test_core.py 프로젝트: devdave/txWeb
def test_site_routeRequest_CorrectlyRoutesToAChildOfstaticFileResource():
    staticDir = Site(RootWithStaticDirectory())
    request = TestRequest([], "/files/a.txt")

    action = staticDir.routeRequest(request)
    response = action.render(request)
    assert not isinstance(action, DirectoryLister)
    assert response == NOT_DONE_YET
    assert request.written[0].count("a") > 0
예제 #3
0
파일: test_core.py 프로젝트: devdave/txWeb
def test_site_routeRequest_CorrectlyHandlesSubDirectories():
    staticDir = Site(RootWithStaticDirectory())

    request = TestRequest([], "/files/subdir/b.txt")

    action = staticDir.routeRequest(request)
    response = action.render(request)
    assert not isinstance(action, DirectoryLister)
    assert response == NOT_DONE_YET
    assert request.written[0].count("b") > 0
예제 #4
0
def test_filtersAreCalled():
    root = Root()
    site = Site(root)
    request = TestRequest([],"/anAction")
    action = site.routeRequest(request)
    assert isinstance(action, OneTimeResource)
    assert action.func == root.anAction
    response = action.render(request)
    assert response == "anActionWasCalled"
    assert getattr(root, "preFilterWasCalled", False) == True
    assert getattr(root, "postFilterWasCalled", False) == True
    
    
    
예제 #5
0
파일: test_core.py 프로젝트: devdave/txWeb
def test_site_routRequest_HandlesIndexAsResource():
    staticSite = Site(RootWithStaticIndex())

    request = TestRequest([], "/")

    action = staticSite.routeRequest(request)
    response = action.render(request)
    assert response == NOT_DONE_YET
    with open(relPath("LICENSE.txt")) as testFile:
        expected = testFile.read()
        assert len(request.written) == 1, "Expected written log to be equal to one"
        actualSize = len(request.written[0])
        expectedSize = len(expected)
        actual = request.written[0]
        assert expectedSize == actualSize, "Expected size doesn't match actual"
        assert expected == actual, "Expecting actual written body to equal expected body"