예제 #1
0
def test_wsgi_starts_on_first_request(wsgi_fixture):
    """A ReahlWSGIApplication can be started automatically when the first request is handled."""
    wsgi_app = ReahlWSGIApplication(wsgi_fixture.config, start_on_first_request=True)
    wsgi_app.system_control = SystemControlStub(wsgi_fixture.config)

    assert not wsgi_app.started
    wsgi_fixture.call_wsgi_app(wsgi_app)
    assert wsgi_app.started
예제 #2
0
    def __init__(self, config, port):
        super(ReahlWebServer, self).__init__()
        self.in_separate_thread = None
        self.running = False
        self.handlers = {}
        self.httpd_thread = None
        certfile = pkg_resources.resource_filename(__name__, 'reahl_development_cert.pem')
        self.reahl_wsgi_app = WrappedApp(ReahlWSGIApplication(config))
        try:
            https_port = port+363
            self.httpd = ReahlWSGIServer.make_server('', port, self.reahl_wsgi_app)
            self.httpsd = SSLCapableWSGIServer.make_server('', https_port, certfile, self.reahl_wsgi_app)
        except socket.error as ex:
            message = ('Caught socket.error: %s\nThis means that another process is using one of these ports: %s, %s. ' % (ex, port, https_port)) \
                     +'\nIf this happens while running tests, it probably means that a browser client did not close its side of a connection to a previous server you had running - and that the server socket now sits in TIME_WAIT state. Is there perhaps a browser hanging around from a previous run? I have no idea how to fix this automatically... see http://hea-www.harvard.edu/~fine/Tech/addrinuse.html'

            raise AssertionError(message)
예제 #3
0
def test_library_files(web_fixture, library_fixture):
    """The files part of configured frontend libraries are (a) added to /static and also (b) included on any page."""

    config = web_fixture.config
    config.web.frontend_libraries.clear()
    config.web.frontend_libraries.add(library_fixture.MyLibrary())

    browser = Browser(ReahlWSGIApplication(config))

    browser.open('/static/somefile.js')
    assert browser.raw_html == 'contents - js'

    browser.open('/static/somefile.css')
    assert browser.raw_html == 'contents - css'

    browser.open('/')
    script_added = browser.get_html_for('//script[@src]')
    assert script_added == '<script type="text/javascript" src="/static/somefile.js"></script>'

    link_added = browser.get_html_for('//link')
    assert link_added == '<link rel="stylesheet" href="/static/somefile.css" type="text/css">'
예제 #4
0
def standard_reahl_files(fixture):
    """The framework includes certain frontent frameworks by default."""

    wsgi_app = ReahlWSGIApplication(fixture.config)
    browser = Browser(wsgi_app)

    browser.open('/static/html5shiv-printshiv-3.6.3.js')
    vassert(browser.last_response.content_length > 0)

    browser.open('/static/IE9.js')
    vassert(browser.last_response.content_length > 0)

    browser.open('/static/reahl.validate.js')
    vassert(browser.last_response.content_length > 0)

    browser.open('/static/reahl.css')
    vassert(browser.last_response.content_length > 0)

    browser.open('/static/runningon.png')
    vassert(browser.last_response.content_length > 0)

    browser.open('/static/reahl.runningonbadge.css')
    vassert(browser.last_response.content_length > 0)
예제 #5
0
import os
from reahl.web.fw import ReahlWSGIApplication
application = ReahlWSGIApplication.from_directory('%s/etc' %
                                                  os.path.expanduser('~'),
                                                  start_on_first_request=True)
예제 #6
0
from reahl.web.fw import ReahlWSGIApplication
application = ReahlWSGIApplication.from_directory('/etc/reahl.d/hellonginx',
                                                  start_on_first_request=True)
예제 #7
0
from __future__ import print_function, unicode_literals, absolute_import, division
from reahl.web.fw import ReahlWSGIApplication
application = ReahlWSGIApplication.from_directory('/etc/reahl.d/hellonginx')
application.start()

예제 #8
0
from reahl.web.fw import ReahlWSGIApplication
application = ReahlWSGIApplication.from_directory('/etc/app-reahl', start_on_first_request=True)