Beispiel #1
0
def test_register_additional_site():
    test_case = "/index.html"
    test_response = "/static/index.html"
    hr = Highroller()
    response = hr.register_additional_site(test_case)
    assert response == test_response
    assert [(test_case, test_response)] == hr.additional_sites

    # add again the same thing, nothing should change
    response = hr.register_additional_site(test_case)
    assert response == test_response
    assert [(test_case, test_response)] == hr.additional_sites
Beispiel #2
0
def test_inject():
    def _get_content_custom(self):
        response = """<html><head></head><body><h1>It works!</h1></body></html>"""
        return response

    hr = Highroller()
    hr._get_content = _get_content_custom
    hr.inject_head = "<!-- headinject -->"
    hr.inject_body = "<!-- bodyinject -->"
    hr.register_additional_site("/index.html")
    assert len(hr.additional_sites) == 1
    for element in hr.additional_sites:
        response = hr.roll_site(element)
        assert response == """<html><head><!-- headinject --></head><body><h1>It works!</h1><!-- bodyinject --></body></html>"""
Beispiel #3
0
from highroller import Highroller    
hr = Highroller()
hr.domain = "http://localhost"
hr.inject_head = "<!-- headinject -->"
hr.inject_body = "<!-- bodyinject -->"
hr.register_additional_site("/index.html")
for element in hr.additional_sites:
    print "roll: {0}".format(element[0])
    hr.roll_site(element)