def test_found_file_prod(monkeypatch, settings):
    settings.DEBUG = False

    application = wsgi_django_media.DjangoMedia(wsgi_app)
    app = _TestApp(application)
    response = app.get('/media/test.txt', status=404)
    assert response.unicode_body.strip() == "No no no"
Exemplo n.º 2
0
    def get_app(self, in_protocol, suffix, _operation_name=None,
                _in_message_name=None):
        """setup testapp dependent on suffix and _in_message_name"""

        import spyne.const
        spyne.const.REQUEST_SUFFIX = suffix

        class EchoService(Service):

            srpc_kparams = {'_returns': Iterable(Unicode)}
            if _in_message_name:
                srpc_kparams['_in_message_name'] = _in_message_name
            if _operation_name:
                srpc_kparams['_operation_name'] = _operation_name

            @srpc(Unicode, Integer, **srpc_kparams)
            def echo(string, times):
                for i in range(times):
                    yield 'Echo, %s' % string

        application = Application([EchoService],
            tns='spyne.examples.echo',
            in_protocol=in_protocol,
            out_protocol=Soap11()
        )
        app = WsgiApplication(application)

        testapp = _TestApp(app)

        # so that it doesn't interfere with other tests.
        spyne.const.REQUEST_SUFFIX = ''

        return testapp
def test_found_file_debug(monkeypatch, settings):
    settings.DEBUG = True

    application = wsgi_django_media.DjangoMedia(wsgi_app)
    app = _TestApp(application)
    response = app.get('/media/test.txt', status=200)
    assert response.unicode_body.strip() == "Yes, it works yes"
def test_found_file_no_escape(monkeypatch, settings):
    settings.DEBUG = True

    application = wsgi_django_media.DjangoMedia(wsgi_app)
    app = _TestApp(application)
    response = app.get('/media/../conftest.py', status=404)
    assert response.unicode_body.strip() == "No no no"
Exemplo n.º 5
0
def test_completed_job_available(test_repository, completed_jobs_stored):
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name}))
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'completed'
def test_debug_external(monkeypatch, settings):
    settings.DEBUG = True
    settings.MEDIA_URL = 'http://localhost/'

    application = wsgi_django_media.DjangoMedia(wsgi_app)
    app = _TestApp(application)
    response = app.get('/media/test.txt', status=404)
    assert response.unicode_body.strip() == "No no no"
Exemplo n.º 7
0
def test_completed_job_available(test_repository, completed_jobs_stored):
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name})
    )
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'completed'
Exemplo n.º 8
0
def test_finished_job_to_running(test_repository, completed_jobs_stored,
                                 running_jobs_stored):
    """
    tests that a job finished cannot change state
    """
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name}))
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'completed'
Exemplo n.º 9
0
    def setUp(self):
        app = main({}, **{
            'sqlalchemy.url': get_sqlalchemy_database(),
            'redis.unixsocket': self.redis_unixsocket,
        })
        session_factory = app.registry['dbsession_factory']
        self.engine = session_factory.kw['bind']
        self.session = get_tm_session(session_factory, transaction.manager)
        Base.metadata.create_all(self.engine)

        self.ts = TrafficStore(self.redis_unixsocket)

        self.app = _TestApp(app)
Exemplo n.º 10
0
def test_running_job_to_pending(test_repository, running_jobs_stored,
                                pending_jobs_stored):
    """
    tests that a job transition from pending to running
    cannot happen
    """
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name}))
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'running'
Exemplo n.º 11
0
def test_finished_job_to_running(test_repository, completed_jobs_stored,
                                 running_jobs_stored):
    """
    tests that a job finished cannot change state
    """
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name})
    )
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'completed'
Exemplo n.º 12
0
def test_pending_stored_to_running_loaded(test_repository, pending_jobs_stored,
                                          running_jobs_stored):
    """
    tests a job transition from pending to running
    given a loaded pending job, if I store and load the same job with status running,
    the latter is shown in the jobs endpoint
    """
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name}))
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'running'
Exemplo n.º 13
0
def test_running_job_to_pending(test_repository, running_jobs_stored,
                                pending_jobs_stored):
    """
    tests that a job transition from pending to running
    cannot happen
    """
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name})
    )
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'running'
Exemplo n.º 14
0
def test_pending_stored_to_running_loaded(test_repository, pending_jobs_stored,
                                          running_jobs_stored):
    """
    tests a job transition from pending to running
    given a loaded pending job, if I store and load the same job with status running,
    the latter is shown in the jobs endpoint
    """
    webapp = _TestApp(application)
    resp = webapp.get(
        reverse("jobs-list", kwargs={"project": test_repository.name})
    )
    jobs = resp.json

    assert len(jobs['results']) == 1
    assert jobs['results'][0]['state'] == 'running'
Exemplo n.º 15
0
def testapp(settings):
    from pyramid.config import Configurator
    with Configurator(settings=settings) as config:
        config.include('ninjadog')
        config.add_route('home', '/')
        config.add_view(
            lambda request: {
                'title': 'title',
                'subtitle': 'subtitle',
                'content': 'This is a paragraph'
            },
            route_name='home',
            renderer='./templates/child.pug',
        )
        app = config.make_wsgi_app()

        yield _TestApp(app)
Exemplo n.º 16
0
def app():
    my_app = main({})
    app = _TestApp(my_app)
    return app
Exemplo n.º 17
0
def widget_app():
    config = Configurator()
    config.include("tests.pkgs.widgetapp")
    return _TestApp(config.make_wsgi_app())