def test_paginated_site(config):
    strange_case(config)

    path_contents = {
        'index.html': True,
        'blogs': {
            'index.html': [
                '<li><a href="/blogs/2012_01_01_post1.html">Post1</a></li>',
                '<li><a href="/blogs/2012_01_02_post2.html">Post2</a></li>',
                '<p>&lsaquo; First</p>',
                '<p>Page 1 of 3, items 1 to 2</p>',
                '<a href="/blogs/pagina2.html">Página 2</a> &rsaquo;'
            ],
            'pagina2.html': [
                '<li><a href="/blogs/2012_01_03_post3.html">Post3</a></li>',
                '<li><a href="/blogs/2012_01_04_post4.html">Post4</a></li>',
                '<p>&lsaquo; <a href="/blogs/">Blogs</a></p>',
                '<p>Page 2 of 3, items 3 to 4</p>',
                '<a href="/blogs/pagina3.html">Página 3</a> &rsaquo;'
            ],
            'pagina3.html': [
                '<li><a href="/blogs/2012_01_05_post5.html">Post5</a></li>',
                '<p>&lsaquo; <a href="/blogs/pagina2.html">Página 2</a></p>',
                '<p>Page 3 of 3, item 5</p>',
                '<p>&rsaquo; Last</p>'
            ],
            '2012_01_01_post1.html': True,
            '2012_01_02_post2.html': True,
            '2012_01_03_post3.html': True,
            '2012_01_04_post4.html': True,
            '2012_01_05_post5.html': True,
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
Beispiel #2
0
def test_config_plugin_site(config):
    run()

    path_contents = {
        'index.html': """<doctype html>
<body>
<h1 id="welcome-to-my-blog">Welcome to my blog!</h1>

<p>It is so UGLY!.</p>
</body>""",
            'blogs': {
                'index.html': """<doctype html>
<body>
<p>My blogs:</p>

<ol>
<li><p><a href="/blogs/2012_01_01_post1.html">BIRD Post1 BIRD</a></p></li>
<li><p><a href="/blogs/2012_01_02_post2.html">BIRD Post2 BIRD</a></p></li>
</ol>
<p>Hi!</p>

</body>""",
            '2012_01_01_post1.html': True,
            '2012_01_02_post2.html': True,
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
Beispiel #3
0
def test_root_url_site(config):
    config['root_url'] = 'root'

    strange_case(config)

    path_contents = {
        '001_2012_01_16_file.html': '1. 2012-01-16',
        'index.html': """<doctype html>
<body>
<h1 id="welcome-to-my-blog">Welcome to my blog!</h1>

<p>It is pretty great.</p>
</body>""",
            'blogs': {
                'index.html': """<doctype html>
<body>
<p>My blogs:</p>

<ol>
<li><p><a href="/root/blogs/2012_01_01_post1.html">Post1</a></p></li>
<li><p><a href="/root/blogs/2012_01_02_post2.html">Post2</a></p></li>
</ol>
<p>Hi!</p>

</body>""",
            '2012_01_01_post1.html': True,
            '2012_01_02_post2.html': True,
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_override(config):
    # override configs that are otherwise not inherited,
    # but config.yaml and front matter should
    # override *that*
    strange_case(config)

    path_contents = {
        'overridden_from_files.html': '<h1>Overridden from files</h1>',
        'overridden_from_front_matter.html': '<h1>Overridden from front matter</h1>',
        'not_overridden.html': '<h1>Overridden</h1>',
        'index.html': '''<h1>Root title</h1>

/not_overridden.html => <h2>Overridden</h2>
/overridden_from_files.html => <h2>Overridden from files</h2>
/overridden_from_front_matter.html => <h2>Overridden from front matter</h2>''',
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_filters_site(config):
    strange_case(config)

    path_contents = {
        'index.html': """
12 May 2012
Sat May 12 09:59:11 2012

<p>Some <em>markdown</em> text</p>

d8f4590320e1343a915b6394170650a8f35d6926

words

["more\\n\\ttext"]

d15aacfd-62b6-594e-93cf-85baa5e441ec""",
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_basic_site_remove_existing(config):
    # create extra files
    # this file does not exist in path_contents, and so
    # should be removed
    os.mkdir(config['deploy_path'])
    with open(join(config['deploy_path'], 'rm_this'), 'w') as f:
        f.write('blablabla')

    strange_case(config)

    path_contents = {
        '001_2012_01_16_file.html': True,
        'index.html': True,
        'blogs': {
            'index.html': True,
            '2012_01_01_post1.html': True,
            '2012_01_02_post2.html': True,
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_basic_site_remove_existing(config):
    # create extra files
    # this file does not exist in path_contents, and so
    # should be removed
    os.mkdir(config['deploy_path'])
    with open(join(config['deploy_path'], 'rm_this'), 'w') as f:
        f.write('blablabla')

    strange_case(config)

    path_contents = {
        '001_2012_01_16_file.html': True,
        'index.html': True,
        'blogs': {
            'index.html': True,
            '2012_01_01_post1.html': True,
            '2012_01_02_post2.html': True,
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
Beispiel #8
0
def test_strip_extensions_site(config):
    config['configurators'].append('strange_case.extensions.configurators.strip_extensions')

    try:
        strange_case(config)
    except Exception:
        tree(config['site_path'], config['project_path'])
        tree(config['deploy_path'], config['project_path'])
        raise

    path_contents = {
        '001_2012_01_16_file.html': '1. 2012-01-16',
        'index.html': """<doctype html>
<body>
<h1 id="welcome-to-my-blog">Welcome to my blog!</h1>

<p>It is pretty great.</p>
</body>""",
            'blogs': {
                'index.html': """<doctype html>
<body>
<p>My blogs:</p>

<ol>
<li><p><a href="/blogs/2012_01_01_post1">Post1</a></p></li>
<li><p><a href="/blogs/2012_01_02_post2">Post2</a></p></li>
</ol>
<p>Hi!</p>

</body>""",
            '2012_01_01_post1.html': """<doctype html>
<body>
<p>My first post, on 2012-01-01.</p>
</body>""",
            '2012_01_02_post2.html': """<doctype html>
<body>
<p>My second post, on 2012-01-02.</p>
</body>""",
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_override(config):
    # override configs that are otherwise not inherited,
    # but config.yaml and front matter should
    # override *that*
    strange_case(config)

    path_contents = {
        'overridden_from_files.html':
        '<h1>Overridden from files</h1>',
        'overridden_from_front_matter.html':
        '<h1>Overridden from front matter</h1>',
        'not_overridden.html':
        '<h1>Overridden</h1>',
        'index.html':
        '''<h1>Root title</h1>

/not_overridden.html => <h2>Overridden</h2>
/overridden_from_files.html => <h2>Overridden from files</h2>
/overridden_from_front_matter.html => <h2>Overridden from front matter</h2>''',
    }
    check_path_contents(config['deploy_path'], path_contents)
Beispiel #10
0
def test_category_site(config):
    strange_case(config)

    path_contents = {
        'index.html': True,
        'blogs': {
            'index.html': True,
            '2012_01_01_post1.html': True,
            '2012_01_02_post2.html': True,
        },
        'zee_categories': {
            'index.html': [
                'Categories (2)',
                '<a href="/zee_categories/good.html">good</a>',
                '<a href="/zee_categories/bad.html">bad</a>'
            ],
            'good.html': ['Category: good', 'Boring category page.'],
            'bad.html': ['Category: bad', 'This category is bad.'],
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_strip_extensions_and_meta_site(config):
    config['configurators'].append('strange_case.extensions.configurators.strip_extensions')
    config['strip_metadata_from_name'] = True
    config['strip_metadata_from_target_name'] = True

    strange_case(config)

    path_contents = {
        'file.html': '1. 2012-01-16',
        'index.html': """<doctype html>
<body>
<h1 id="welcome-to-my-blog">Welcome to my blog!</h1>

<p>It is pretty great.</p>
</body>""",
            'blogs': {
                'index.html': """<doctype html>
<body>
<p>My blogs:</p>

<ol>
<li><p><a href="/blogs/post1">Post1</a></p></li>
<li><p><a href="/blogs/post2">Post2</a></p></li>
</ol>
<p>Hi!</p>

</body>""",
            'post1.html': """<doctype html>
<body>
<p>My first post, on 2012-01-01.</p>
</body>""",
            'post2.html': """<doctype html>
<body>
<p>My second post, on 2012-01-02.</p>
</body>""",
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_filters_site(config):
    strange_case(config)

    path_contents = {
        'index.html':
        """
12 May 2012
Sat May 12 09:59:11 2012

12 May 2012
Sat May 12 09:59:11 2012

<p>Some <em>markdown</em> text</p>

d8f4590320e1343a915b6394170650a8f35d6926

words

["more\\n\\ttext"]

d15aacfd-62b6-594e-93cf-85baa5e441ec""",
    }
    check_path_contents(config['deploy_path'], path_contents)
def test_paginated_site(config):
    strange_case(config)

    path_contents = {
        'index.html': True,
        'blogs': {
            'index.html': [
                '<li><a href="/blogs/2012_01_01_post1.html">Post1</a></li>',
                '<li><a href="/blogs/2012_01_02_post2.html">Post2</a></li>',
                '<p>&lsaquo; First</p>', '<p>Page 1 of 3, items 1 to 2</p>',
                '<a href="/blogs/pagina2.html">Página 2</a> &rsaquo;'
            ],
            'pagina2.html': [
                '<li><a href="/blogs/2012_01_03_post3.html">Post3</a></li>',
                '<li><a href="/blogs/2012_01_04_post4.html">Post4</a></li>',
                '<p>&lsaquo; <a href="/blogs/">Blogs</a></p>',
                '<p>Page 2 of 3, items 3 to 4</p>',
                '<a href="/blogs/pagina3.html">Página 3</a> &rsaquo;'
            ],
            'pagina3.html': [
                '<li><a href="/blogs/2012_01_05_post5.html">Post5</a></li>',
                '<p>&lsaquo; <a href="/blogs/pagina2.html">Página 2</a></p>',
                '<p>Page 3 of 3, item 5</p>', '<p>&rsaquo; Last</p>'
            ],
            '2012_01_01_post1.html':
            True,
            '2012_01_02_post2.html':
            True,
            '2012_01_03_post3.html':
            True,
            '2012_01_04_post4.html':
            True,
            '2012_01_05_post5.html':
            True,
        },
    }
    check_path_contents(config['deploy_path'], path_contents)
Beispiel #14
0
def test_basic_site(basic_config):
    strange_case(basic_config)

    path_contents = {
        '001_2012_01_16_file.html': '1. 2012-01-16',
        'index.html': """<doctype html>
<body>
<h1 id="welcome-to-my-blog">Welcome to my blog!</h1>

<p>It is pretty great.</p>
</body>""",
        'blogs': {
            'index.html':
            """<doctype html>
<body>
<p>My blogs:</p>

<ol>
<li><p><a href="/blogs/2012_01_01_post1.html">Post1</a></p></li>
<li><p><a href="/blogs/2012_01_02_post2.html">Post2</a></p></li>
</ol>
<p>Hi!</p>

</body>""",
            '2012_01_01_post1.html':
            """<doctype html>
<body>
<p>My first post, on 2012-01-01.</p>
</body>""",
            '2012_01_02_post2.html':
            """<doctype html>
<body>
<p>My second post, on 2012-01-02.</p>
</body>""",
        },
    }
    check_path_contents(basic_config['deploy_path'], path_contents)