Skip to content

Commit

Permalink
real world testing results
Browse files Browse the repository at this point in the history
  • Loading branch information
jpsca committed Jan 12, 2013
1 parent 5539e4c commit 2e41512
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 13 deletions.
9 changes: 4 additions & 5 deletions Makefile
Expand Up @@ -6,14 +6,13 @@ clean: clean-pyc
rm -rf build
rm -rf dist
rm -rf *.egg-info
rm -rf tests/res/t
find . -name '.DS_Store' -exec rm -f {} \;
find . -name '.DS_Store' -delete
rm -rf tests/__pycache__

clean-pyc:
find . -name '*.pyc' -exec rm -f {} \;
find . -name '*.pyo' -exec rm -f {} \;
find . -name '*~' -exec rm -f {} \;
find . -name '*.pyc' -delete
find . -name '*.pyo' -delete
find . -name '*~' -delete

test:
py.test --cov-config .coveragerc --cov clay tests/
Expand Down
2 changes: 1 addition & 1 deletion clay/__init__.py
Expand Up @@ -13,4 +13,4 @@
from main import Clay


__version__ = '2.0'
__version__ = '2.2'
4 changes: 2 additions & 2 deletions clay/main.py
Expand Up @@ -10,7 +10,7 @@
import socket

from flask import (Flask, request, has_request_context, render_template,
send_file, make_response, abort)
make_response, abort, send_file)
from jinja2 import ChoiceLoader, FileSystemLoader, PackageLoader
from jinja2.exceptions import TemplateNotFound
import yaml
Expand Down Expand Up @@ -38,7 +38,7 @@
SOURCE_NOT_FOUND = u"""We couldn't found a "%s" dir.
Are you sure you're in the correct folder? """ % SOURCE_DIRNAME

rx_abs_url = re.compile(r'\s(src|href)=[\'"](\/(?:[a-z0-9][^\'"]*)?)[\'"]',
rx_abs_url = re.compile(r'\s(src|href|data-[a-z0-9_-]+)\s*=\s*[\'"](\/(?:[a-z0-9_-][^\'"]*)?)[\'"]',
re.UNICODE | re.IGNORECASE)


Expand Down
4 changes: 0 additions & 4 deletions clay/skeleton/settings.yml
Expand Up @@ -11,10 +11,6 @@ FILTER:
INCLUDE:
#

## Enabled post-processors
POST_PROCESSORS:
# - pygments

## Server
HOST: 0.0.0.0
PORT: 8080
Expand Down
2 changes: 1 addition & 1 deletion docs/es/intro.md
Expand Up @@ -21,7 +21,7 @@ Puedes tener una versión "compilada" del sitio en un instante: los HTMLs de tod
## Pensamos en todos los detalles
- Cuando compilas o mientras desarrolla, un "_index.html" también se genera con una lista de todas las páginas, inclusive esas a los que no puedes llegar navegando normalmente, como la 404.html. Así no tienes por que recordar los nombres de las páginas o listarlas en un email. ¡Práctico!
- ¿Simular la página activa en la navegación principal? Muy fácil.
- Los valores que pongas en tu `settings.yml` (¿un nombre? ¿el APPID de Facebook?) los podrás usar en todo el sitio.
- Los valores que pongas en tu `settings.yml` los podrás usar en todo el sitio.



Expand Down
33 changes: 33 additions & 0 deletions tests/test_build.py
Expand Up @@ -145,6 +145,7 @@ def test_translate_absolute_to_relative(c):
<link href="/styles/reset.css">
<link href="/styles/test.css">
<script src="/scripts/main.js"></script>
<img src="/static/img.jpg" data-src="/static/imgBig.jpg">
</head><body></body></html>"""
create_file(sp1, content % 'wtf')
create_file(sp2, content % 'foo/wtf')
Expand All @@ -155,10 +156,12 @@ def test_translate_absolute_to_relative(c):
assert '<link href="styles/reset.css">' in page
assert '<link href="styles/test.css">' in page
assert '<script src="scripts/main.js">' in page
assert '<img src="static/img.jpg" data-src="static/imgBig.jpg">' in page
page = read_content(bp2)
assert '<link href="../styles/reset.css">' in page
assert '<link href="../styles/test.css">' in page
assert '<script src="../scripts/main.js">' in page
assert '<img src="../static/img.jpg" data-src="../static/imgBig.jpg">' in page


def test_translate_absolute_to_relative_index(c):
Expand Down Expand Up @@ -269,6 +272,36 @@ def test_build__index(c):
assert 'href="ddd.html"' in page


def test_build__index(c):
setup_module()
make_dirs(SOURCE_DIR, 'bbb')

sp1, bp1 = get_file_paths('aaa.html')
sp2, bp2 = get_file_paths('eee.html')
sp3, bp3 = get_file_paths('bbb/aa.html')
sp4, bp4 = get_file_paths('bbb/zz.html')
sp5, bp5 = get_file_paths('bbb/ccc.html')
sp6, bp6 = get_file_paths('ddd.html')
sp7, bp7 = get_file_paths('bbb/bb.html')
create_file(sp1, HTML)
create_file(sp2, HTML)
create_file(sp3, HTML)
create_file(sp4, HTML)
create_file(sp5, HTML)
create_file(sp6, HTML)
create_file(sp7, HTML)
c.build()

bpindex = get_build_path('_index.html')
page = read_content(bpindex)
assert page.find('href="aaa.html"') < page.find('href="ddd.html"')
assert page.find('href="ddd.html"') < page.find('href="eee.html"')
assert page.find('href="eee.html"') < page.find('href="bbb/aa.html"')
assert page.find('href="bbb/aa.html"') < page.find('href="bbb/bb.html"')
assert page.find('href="bbb/bb.html"') < page.find('href="bbb/ccc.html"')
assert page.find('href="bbb/ccc.html"') < page.find('href="bbb/zz.html"')


def test_do_not_include_non_template_files_in__index(c):
setup_module()
bpindex = get_build_path('_index.html')
Expand Down
21 changes: 21 additions & 0 deletions tests/test_main.py
Expand Up @@ -151,6 +151,27 @@ def test_show__index(t):
assert 'href="ddd.html"' in page


def test__index_is_sorted(t):
setup_module()
make_dirs(SOURCE_DIR, 'bbb')

create_file(get_source_path('bbb.html'), HTML)
create_file(get_source_path('bbb/aa.html'), HTML)
create_file(get_source_path('bbb/ccc.html'), HTML)
create_file(get_source_path('aaa.html'), HTML)
create_file(get_source_path('ddd.html'), HTML)

resp = t.get('/_index.html')
assert resp.status_code == HTTP_OK
assert resp.mimetype == 'text/html'

page = resp.data
assert page.find('href="aaa.html"') < page.find('href="bbb.html"')
assert page.find('href="bbb.html"') < page.find('href="ddd.html"')
assert page.find('href="ddd.html"') < page.find('href="bbb/aa.html"')
assert page.find('href="bbb/aa.html"') < page.find('href="bbb/ccc.html"')


def test_do_not_include_non_template_files_in__index(t):
setup_module()
create_file(get_source_path('main.js'), "/* {% foobar %} */")
Expand Down

0 comments on commit 2e41512

Please sign in to comment.