コード例 #1
0
ファイル: test_main.py プロジェクト: PavloKapyshin/Clay
def test_values_as_template_context():
    c = Clay(TESTS)
    t = c.get_test_client()
    create_file(get_source_path('hello.html'), u'Hello {{ who }}!')
    resp = t.get('/hello.html?who=world')
    assert resp.status_code == HTTP_OK
    assert resp.data == 'Hello world!'
    assert resp.mimetype == 'text/html'
コード例 #2
0
def test_values_as_template_context():
    c = Clay(TESTS)
    t = c.get_test_client()
    create_file(get_source_path('hello.html'), u'Hello {{ who }}!')
    resp = t.get('/hello.html?who=world')
    assert resp.status_code == HTTP_OK
    assert resp.data.decode() == 'Hello world!'
    assert resp.mimetype == 'text/html'
コード例 #3
0
def test_load_settings_from_file():
    c = Clay(TESTS)
    assert 'foo' not in c.settings

    stpath = os.path.join(TESTS, 'settings.py')
    create_file(stpath, "\nfoo='bar'\n")
    c = Clay(TESTS)
    remove_file(stpath)
    assert 'foo' in c.settings
コード例 #4
0
def test_settings_as_template_context():

    c = Clay(TESTS, {'who': u'world'})
    t = c.get_test_client()
    create_file(get_source_path('hello.html'), u'Hello {{ who }}!')
    resp = t.get('/hello.html')
    assert resp.status_code == HTTP_OK
    assert resp.data == 'Hello world!'
    assert resp.mimetype == 'text/html'
コード例 #5
0
ファイル: test_build.py プロジェクト: alexander-ae/Clay
def test_settings_as_template_build_context():
    c = Clay(TESTS, {'who': u'world', 'FILTER_PARTIALS': False})
    name = 'test.txt.tmpl'
    sp = get_source_path(name)
    bp = get_build_path('test.txt')
    create_file(sp, u'Hello {{ who }}!')

    c.build_page(name)
    assert read_content(bp) == u'Hello world!'
コード例 #6
0
ファイル: test_build.py プロジェクト: ikcam/Clay
def test_settings_as_template_build_context():
    c = Clay(TESTS, {'who': u'world', 'FILTER_PARTIALS': False})
    name = 'test.txt.tmpl'
    sp = get_source_path(name)
    bp = get_build_path('test.txt')
    create_file(sp, u'Hello {{ who }}!')

    c.build_page(name)
    assert read_content(bp) == u'Hello world!'
コード例 #7
0
def test_fix_settings():
    bad_settings = dict(
        FILTER_PARTIALS=None,
        FILTER=None,
        INCLUDE=None,
        HOST=None,
        PORT=None,
    )
    c = Clay(TESTS, bad_settings)
    create_page('test.html', HTML)
    c.get_pages_index()
コード例 #8
0
def test_setup_with_settings():
    c = Clay(TESTS, {'foo': 'bar'})
    assert 'foo' in c.settings
コード例 #9
0
def test_setup_with_filename_as_root():
    assert Clay(__file__)
コード例 #10
0
ファイル: conftest.py プロジェクト: ikcam/Clay
def c():
    return Clay(TESTS, {'foo': 'bar'})
コード例 #11
0
ファイル: test_exceptions.py プロジェクト: juanolon/Clay
def test_fix_settings():
    bad_settings = dict(FILTER_PARTIALS=None, FILTER=None, INCLUDE=None, HOST=None, PORT=None)
    c = Clay(TESTS, bad_settings)
    create_page("test.html", HTML)
    c.get_pages_index()
コード例 #12
0
ファイル: utils.py プロジェクト: malkarouri/Clay
# -*- coding: utf-8 -*-
import io
import os

from clay import Clay


HTTP_OK = 200
HTTP_NOT_FOUND = 404

clay_ = Clay(__file__)
c = clay_.test_client()


def get_views_filepath(filename):
    return os.path.join(clay_.source_dir, filename)


def get_build_filepath(filename):
    return os.path.join(clay_.build_dir, filename)


def make_file(filepath, content):
    if not isinstance(content, unicode):
        content = unicode(content, 'utf-8')
    with io.open(filepath, 'w+t') as f:
        f.write(content)
    return filepath


def make_view(filename, content):
コード例 #13
0
def c():
    return Clay(TESTS)
コード例 #14
0
ファイル: utils.py プロジェクト: cordoval/Clay
# -*- coding: utf-8 -*-
import io
import os

from clay import Clay


HTTP_OK = 200
HTTP_NOT_FOUND = 404

proto = Clay(__file__)
c = proto.test_client()


def get_views_filepath(filename):
    return os.path.join(proto.source_dir, filename)


def get_build_filepath(filename):
    return os.path.join(proto.build_dir, filename)


def make_file(filepath, content):
    if not isinstance(content, unicode):
        content = unicode(content, 'utf-8')
    with io.open(filepath, 'w+t') as f:
        f.write(content)
    return filepath


def make_view(filename, content):