async def test_simple_file(tmpworkdir, client): mktree(tmpworkdir, { 'foo': 'X', }) r = await client.get('/foo') assert r.status == 200 content = await r.read() assert content == b'X'
async def test_index(tmpworkdir, client): mktree(tmpworkdir, { 'index.html': 'abc', }) r = await client.get('/') assert r.status == 200 content = await r.read() assert content == b'abc'
def test_sass_precision_5(tmpworkdir): mktree(tmpworkdir, {'styles.scss': 'a { width: (100 / 6)px}'}) config = Config(config_dict={'sass': {'precision': 5}}) config.setup() build(config) assert gettree(tmpworkdir.join('build')) == { 'styles.css': 'a {\n width: 16.66667 px; }\n' }
def test_build_sass(tmpworkdir): mktree(tmpworkdir, {'styles.sass': 'a\n b\n color: blue;'}) config = Config() config.setup() build(config) assert gettree(tmpworkdir.join('build')) == { 'styles.css': 'a b {\n color: blue; }\n' }
def test_build_scss_bad(tmpworkdir, logcap): logcap.set_level(logging.ERROR) mktree(tmpworkdir, {'styles.scss': 'x = 42'}) config = Config() config.setup() with pytest.raises(HarrierProblem) as excinfo: build(config) assert excinfo.value.args[0] == 'Error compiling SASS' assert logcap.log == """Error: Invalid CSS after "x": expected "{", was "= 42"
async def test_304(tmpworkdir, client, logcap): logcap.set_logger('dev_server', logging.INFO) mktree(tmpworkdir, { 'foo': 'X', }) r = await client.get('/foo', headers={'IF-MODIFIED-SINCE': 'Mon, 03 Jan 2050 00:00:00 UTC'}) assert r.status == 304 content = await r.read() assert content == b'' assert logcap.log == ' > GET /foo 304 0B\n'
async def test_prefix_file(tmpworkdir, loop, server): app, url = await server('/this_is_prefix/') client = Client(loop, url=url) mktree(tmpworkdir, { 'foo': 'X', }) r = await client.get('/this_is_prefix/foo') assert r.status == 200 content = await r.read() assert content == b'X' client.close()
def test_sass_exclude(tmpworkdir): mktree(tmpworkdir, { 'src': { '_foo.scss': '$primary-colour: #016997;', 'bar.scss': """\ @import 'foo'; body { color: $primary-colour; }""" }, 'harrier.yml': '\nroot: src' }) config = Config() config.setup() build(config) assert gettree(tmpworkdir.join('build')) == {'bar.css': 'body {\n color: #016997; }\n'}
async def test_404(tmpworkdir, loop, server): app, url = await server('/this_is_prefix/') client = Client(loop, url=url) mktree(tmpworkdir, { 'foo': 'X', }) r = await client.get('/this_is_prefix/foo') assert r.status == 200 content = await r.read() assert content == b'X' r = await client.get('/this_is_prefix/foobar') assert r.status == 404 content = await r.read() assert content == b'404: Not Found\n\n' r = await client.get('/foobar') assert r.status == 404 content = await r.read() assert content == b'404: Not Found (files are being served from the subdirectory "/this_is_prefix/" only)\n\n' client.close()
def test_get_asset_content(v, result, tmpworkdir): mktree(tmpworkdir, { 'assets.json': '{"x.js": "wherever/x.js"}', }) assert _get_asset_content(v) == result