Esempio n. 1
0
def test_site_routeRequest_CorrectlyRoutesToAChildOfstaticFileResource():
    staticDir = CSite(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
Esempio n. 2
0
def test_site_routeRequest_HandlesDirectoryListing():

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

    action = staticDir.routeRequest(request)

    response = action.render(request)
    assert isinstance(action, DirectoryLister)
Esempio n. 3
0
def test_site_routeRequest_CorrectlyHandlesSubDirectories():
    staticDir = CSite(RootWithStaticDirectory())

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

    #from dbgp.client import brk; brk("192.168.1.2", 9090)
    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
Esempio n. 4
0
def test_site_routRequest_HandlesIndexAsResource():
    staticSite = CSite(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"