def test_config_default():
    values = {}
    config = PieCrustConfiguration(values=values)
    assert config.get('site/root') == '/'
    assert len(config.get('site/sources').keys()) == \
        len(['theme_assets', 'assets', 'theme_pages', 'pages', 'posts',
             'tags', 'categories', 'archives'])
Example #2
0
def test_config_default():
    values = {}
    config = PieCrustConfiguration(values=values)
    assert config.get('site/root') == '/'
    assert len(config.get('site/sources').keys()) == \
        len(['theme_assets', 'assets', 'theme_pages', 'pages', 'posts',
             'tags', 'categories', 'archives'])
Example #3
0
    def config(self):
        logger.debug("Creating site configuration...")
        start_time = time.perf_counter()

        if not self.theme_site:
            path = os.path.join(self.root_dir, CONFIG_PATH)
        else:
            path = os.path.join(self.root_dir, THEME_CONFIG_PATH)

        theme_path = None
        if not self.theme_site and self.theme_dir:
            theme_path = os.path.join(self.theme_dir, THEME_CONFIG_PATH)

        config_cache = self.cache.getCache('app')
        config = PieCrustConfiguration(
                path=path, theme_path=theme_path,
                cache=config_cache, theme_config=self.theme_site)

        if self.theme_site:
            variant_path = os.path.join(
                    self.root_dir, 'configs', 'theme_preview.yml')
            config.addVariant(variant_path, raise_if_not_found=False)

        self.env.stepTimer('SiteConfigLoad', time.perf_counter() - start_time)
        return config
Example #4
0
def test_config_site_add_source():
    values = {'site': {
        'sources': {'notes': {}},
        'routes': [{'url': '/notes/%path:slug%', 'source': 'notes'}]
        }}
    config = PieCrustConfiguration(values=values)
    # The order of routes is important. Sources, not so much.
    assert list(map(lambda v: v['source'], config.get('site/routes'))) == [
            'notes', 'posts', 'posts', 'posts', 'pages', 'theme_pages']
    assert list(config.get('site/sources').keys()) == [
            'pages', 'posts', 'notes', 'theme_pages']
Example #5
0
    def config(self):
        logger.debug("Creating site configuration...")
        start_time = time.perf_counter()

        if not self.theme_site:
            path = os.path.join(self.root_dir, CONFIG_PATH)
        else:
            path = os.path.join(self.root_dir, THEME_CONFIG_PATH)

        theme_path = None
        if not self.theme_site and self.theme_dir:
            theme_path = os.path.join(self.theme_dir, THEME_CONFIG_PATH)

        config_cache = self.cache.getCache('app')
        config = PieCrustConfiguration(
            path=path, theme_path=theme_path,
            cache=config_cache, theme_config=self.theme_site)

        local_path = os.path.join(
            self.root_dir, 'configs', 'local.yml')
        config.addVariant(local_path, raise_if_not_found=False)

        if self.theme_site:
            variant_path = os.path.join(
                self.root_dir, 'configs', 'theme_preview.yml')
            config.addVariant(variant_path, raise_if_not_found=False)

        self.env.stats.stepTimer('SiteConfigLoad',
                                 time.perf_counter() - start_time)
        return config
Example #6
0
def test_config_default():
    values = {}
    config = PieCrustConfiguration(values=values)
    assert config.get('site/root') == '/'
    assert len(config.get('site/sources')) == 3  # pages, posts, theme_pages
Example #7
0
def test_config_site_override_title():
    values = {'site': {'title': "Whatever"}}
    config = PieCrustConfiguration(values=values)
    assert config.get('site/root') == '/'
    assert config.get('site/title') == 'Whatever'
Example #8
0
def test_config_site_override_title():
    values = {'site': {'title': "Whatever"}}
    config = PieCrustConfiguration(values=values)
    assert config.get('site/root') == '/'
    assert config.get('site/title') == 'Whatever'
Example #9
0
def get_mock_app(config=None):
    app = mock.MagicMock(spec=PieCrust)
    app.config = PieCrustConfiguration(values={})
    return app