Skip to content
Browse files

real world testing results

  • Loading branch information...
1 parent 5539e4c commit 2e4151279a4c3f483e175cfd25f6d6fcbdf103f8 @jpscaletti jpscaletti committed
Showing with 62 additions and 13 deletions.
  1. +4 −5 Makefile
  2. +1 −1 clay/__init__.py
  3. +2 −2 clay/main.py
  4. +0 −4 clay/skeleton/settings.yml
  5. +1 −1 docs/es/intro.md
  6. +33 −0 tests/test_build.py
  7. +21 −0 tests/test_main.py
View
9 Makefile
@@ -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/
View
2 clay/__init__.py
@@ -13,4 +13,4 @@
from main import Clay
-__version__ = '2.0'
+__version__ = '2.2'
View
4 clay/main.py
@@ -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
@@ -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)
View
4 clay/skeleton/settings.yml
@@ -11,10 +11,6 @@ FILTER:
INCLUDE:
#
-## Enabled post-processors
-POST_PROCESSORS:
- # - pygments
-
## Server
HOST: 0.0.0.0
PORT: 8080
View
2 docs/es/intro.md
@@ -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.
View
33 tests/test_build.py
@@ -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')
@@ -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):
@@ -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')
View
21 tests/test_main.py
@@ -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 %} */")

0 comments on commit 2e41512

Please sign in to comment.
Something went wrong with that request. Please try again.