コード例 #1
0
def test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have__www_root(harness):
    foo = os.getcwd()
    os.chdir(harness.fs.project.resolve(''))
    os.rmdir(os.getcwd())
    c = Configurable()
    c.configure(['--www_root', foo])
    assert c.www_root == foo
コード例 #2
0
ファイル: test_configuration.py プロジェクト: buchuki/aspen
def test_nirvana():
    logging.getLogger().handlers = []  # override nose logging nosiness
    c = Configurable()
    c.configure(['-vNIRVANA'])
    actual = c.log_level
    expected = sys.maxint
    assert actual == expected, actual
コード例 #3
0
def test_www_root_defaults_to_cwd(mk):
    mk()
    c = Configurable()
    c.configure([])
    expected = os.path.realpath(os.getcwd())
    actual = c.www_root
    assert actual == expected
コード例 #4
0
ファイル: test_configuration.py プロジェクト: buchuki/aspen
def test_root_defaults_to_cwd():
    mk()
    c = Configurable()
    c.configure([])
    expected = os.getcwd()
    actual = c.root
    assert actual == expected, actual
コード例 #5
0
def test_configurable_sees_root_option(mk):
    mk()
    c = Configurable()
    c.configure(['--www_root', FSFIX])
    expected = os.getcwd()
    actual = c.www_root
    assert actual == expected
コード例 #6
0
ファイル: test_configuration.py プロジェクト: buchuki/aspen
def test_configurable_sees_root_option():
    mk()
    c = Configurable()
    c.configure(['--root', FSFIX])
    expected = os.getcwd()
    actual = c.root
    assert actual == expected, actual
コード例 #7
0
def test_www_root_defaults_to_cwd():
    mk()
    c = Configurable()
    c.configure([])
    expected = os.path.realpath(os.getcwd())
    actual = c.www_root
    assert actual == expected, actual
コード例 #8
0
def test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have__www_root(mk):
    mk()
    foo = os.getcwd()
    os.chdir(FSFIX)
    os.rmdir(os.getcwd())
    c = Configurable()
    c.configure(['--www_root', foo])
    expected = foo
    actual = c.www_root
    assert actual == expected
コード例 #9
0
ファイル: test_configuration.py プロジェクト: buchuki/aspen
def test_ConfigurationError_NOT_raised_if_no_cwd_but_do_have___root():
    mk()
    foo = os.getcwd()
    os.chdir(FSFIX)
    os.rmdir(os.getcwd())
    c = Configurable()
    c.configure(['--root', foo])
    expected = foo
    actual = c.root
    assert actual == expected, actual
コード例 #10
0
ファイル: __init__.py プロジェクト: falstaff84/aspen
 def from_fs(cls, fs):
     """Takes a path under ./fsfix using / as the path separator.
     """
     fs = os.sep.join(fs.split('/'))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     c = Configurable.from_argv(['fsfix'])
     c.copy_configuration_to(request)
     request.fs = fs
     request.namespace = {}
     request.website = Stub()
     request.website.template_loader = Stub()
     return request
コード例 #11
0
ファイル: test_configuration.py プロジェクト: jaraco/aspen
def test_defaults_to_defaults(harness):
    c = Configurable()
    c.configure()
    actual = ( c.logging_threshold
             , c.project_root
             , c.www_root

             , c.changes_reload
             , c.charset_dynamic
             , c.charset_static
             , c.indices
             , c.list_directories
             , c.media_type_default
             , c.media_type_json
             , c.renderer_default
             , c.show_tracebacks
              )
    expected = ( 0, None, os.getcwd(), False, 'UTF-8', None
               , ['index.html', 'index.json', 'index', 'index.html.spt', 'index.json.spt', 'index.spt']
               , False, 'text/plain', 'application/json', 'stdlib_percent', False
                )
    assert actual == expected
コード例 #12
0
ファイル: __init__.py プロジェクト: jatr/aspen
 def from_fs(cls, fs):
     """Takes a path under ./fsfix using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Configurable.from_argv(['--root', 'fsfix'])
     website.copy_configuration_to(request)
     request.root = join(dirname(__file__), 'fsfix')
     request.fs = fs
     request.namespace = {}
     request.website = website 
     request.website.template_loader = Stub()
     return request
コード例 #13
0
ファイル: __init__.py プロジェクト: jarpineh/aspen
 def from_fs(cls, fs, *a):
     """Takes a path under FSFIX using / as the path separator.
     """
     fs = os.sep.join(fs.split(os.sep))
     request = Request.from_wsgi(StubWSGIRequest(fs))
     website = Configurable.from_argv([ '--www_root', FSFIX
                                      , '--project_root', '.aspen'
                                       ] + list(a))
     request.www_root = os.path.join(os.path.dirname(__file__), FSFIX)
     request.fs = fs
     request.context = {}
     request.website = website 
     request._media_type = None
     return request
コード例 #14
0
ファイル: test_rendering.py プロジェクト: allisonmobley/aspen
def test_cheese_example():
    mk(('configure-aspen.py', """\
from aspen.renderers import Renderer, Factory

class Cheese(Renderer):
    def render_content(self, context):
        return self.compiled.replace("cheese", "CHEESE!!!!!!")

class CheeseFactory(Factory):
    Renderer = Cheese

website.renderer_factories['excited-about-cheese'] = CheeseFactory(website)
"""))
    website = Configurable.from_argv(["--project_root", FSFIX])
    make_renderer = website.renderer_factories['excited-about-cheese']
    render = make_renderer("", "I like cheese!")  # test specline elsewhere
    actual = render({})
    assert actual == "I like CHEESE!!!!!!!", actual
コード例 #15
0
def test_cheese_example():
    mk(('configure-aspen.py', """\
from aspen.renderers import Renderer, Factory

class Cheese(Renderer):
    def render_content(self, context):
        return self.compiled.replace("cheese", "CHEESE!!!!!!")

class CheeseFactory(Factory):
    Renderer = Cheese

website.renderer_factories['excited-about-cheese'] = CheeseFactory(website)
"""))
    website = Configurable.from_argv(["--project_root", FSFIX])
    make_renderer = website.renderer_factories['excited-about-cheese']
    render = make_renderer("", "I like cheese!")  # test specline elsewhere
    actual = render({})
    assert actual == "I like CHEESE!!!!!!!", actual
コード例 #16
0
def tornado_factory_factory(argv=None):
    if argv is None:
        argv = []
    return TornadoFactory(Configurable.from_argv(argv))
コード例 #17
0
def test_that_a_renderer_factory_is_instantiable():
    actual = TornadoFactory(Configurable.from_argv([])).__class__
    assert actual is TornadoFactory, actual
コード例 #18
0
def test_configuration_scripts_arent_confused_by_io_errors(mk):
    CONFIG = "open('this file should not exist')\n"
    mk(('configure-aspen.py', CONFIG))
    c = Configurable()
    actual = raises(IOError, c.configure, ['-p', FSFIX]).value
    assert actual.strerror == 'No such file or directory'
コード例 #19
0
def test_ConfigurationError_raised_if_no_cwd(mk):
    mk()
    os.chdir(FSFIX)
    os.rmdir(FSFIX)
    c = Configurable()
    raises(ConfigurationError, c.configure, [])
コード例 #20
0
def test_configurable_sees_root_option(harness):
    c = Configurable()
    c.configure(['--www_root', harness.fs.project.resolve('')])
    expected = harness.fs.project.root
    actual = c.www_root
    assert actual == expected
コード例 #21
0
ファイル: test_gauntlet.py プロジェクト: geekbuntu/aspen
 def __init__(self, path):
     self.path = Path(path)
     c = Configurable.from_argv(['fsfix'])
     c.copy_configuration_to(self)
コード例 #22
0
ファイル: test_rendering.py プロジェクト: allisonmobley/aspen
def tornado_factory_factory(argv=None):
    if argv is None:
        argv = []
    return TornadoFactory(Configurable.from_argv(argv))
コード例 #23
0
ファイル: test_configuration.py プロジェクト: jaraco/aspen
def test_logging_threshold_goes_to_eleven():
    c = Configurable()
    c.configure(logging_threshold='11')
    assert c.logging_threshold == 11
コード例 #24
0
ファイル: test_rendering.py プロジェクト: allisonmobley/aspen
def test_that_a_renderer_factory_is_instantiable():
    actual = TornadoFactory(Configurable.from_argv([])).__class__
    assert actual is TornadoFactory, actual