Example #1
0
    def _run_test(self, settings):
        """ Run a simple pyramid app and check that serving files works """
        config = Configurator(settings=settings)
        config.include('pike')
        files = {
            'foo.html': b'<h1>hello world</h1>',
            'foo.js': b"alert('hello world');",
        }
        self.make_files(files)
        env = config.get_pike_env()
        with pike.Graph('assets') as graph:
            pike.glob('.', '*')
        env.add(graph)
        env.run_all()

        app = webtest.TestApp(config.make_wsgi_app())
        # Fetch a file
        response = app.get('/gen/foo.html')
        self.assertEqual(response.body, files['foo.html'])

        # Fetch a missing file
        response = app.get('/gen/foo.bar', expect_errors=True)
        self.assertEqual(response.status_code, 404)