Skip to content

Commit

Permalink
[enh] Improved tests coverage a lot
Browse files Browse the repository at this point in the history
  • Loading branch information
oksome committed Feb 4, 2014
1 parent 3c2c6c1 commit 068b9b2
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 13 deletions.
25 changes: 19 additions & 6 deletions samples/bottle_webapp/templates/index.tpl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,32 @@
from tumulus.plugins import inject_css, inject_js_footer, inject_js_head
import tumulus.lib as lib


def truc(title):
global lib
return t.div(
t.h2(title),
t.p('Bla bla bla', class_='btn btn-info'),


lib.css('bootstrap'),
)

page = t.html(
t.head(
t.meta(charset="utf-8"),
),
t.body(
t.h1("A page"),
t.p("Yup, this is a page on the World Wild Web."),
inject_css('http://okso.me/static/style.css'),
# inject_css('http://okso.me/static/style.css'),

lib.js('d3'),
lib.js('jquery'),
lib.js('http://d3js.org/d3.v3.min.js'),
lib.js('bootstrap'),
lib.css('bootstrap'),
truc('Salut les amis'),

# lib.js('d3'),
# lib.js('jquery'),
# lib.js('http://d3js.org/d3.v3.min.js'),
# lib.js('bootstrap'),
# lib.css('bootstrap'),
),
)
6 changes: 6 additions & 0 deletions tests/test_embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@

import tumulus.embed as e


def test_youtube():
r = e.youtube('dQw4w9WgXcQ')
r.build()


def test_vimeo():
r = e.vimeo('75260457')
r.build()
11 changes: 10 additions & 1 deletion tests/test_formulas.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,19 @@
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from tumulus.tags import HTMLTags as t
import tumulus.formulas as f


def test_css():
r = f.css('style.css')
r.build()


def test_mobile():
r = f.mobile()
assert r


def test_utf8():
r = f.utf8()
r.build()
54 changes: 50 additions & 4 deletions tests/test_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,68 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.

from tumulus.tags import HTMLTags as t
from tumulus.plugins import inject_css
from tumulus.plugins import inject_css, inject_js_head, inject_js_footer


def test_plugin():
def test_inject_css():
page = t.html(
t.head(
t.meta(charset="utf-8"),
),
t.body(
t.h1("A page"),
t.p("Yup, this is a page on the World Wild Web."),
inject_css('http://example.com/style.css'),
inject_css('https://example.com/style.css'),
),
)
assert page
result = page.build()
assert result
assert '<link href="http://example.com/style.css" ' \
assert '<link href="https://example.com/style.css" ' \
'rel="stylesheet" type="text/css">' in result


def test_inject_css_nohead():
page = t.html(
t.body(
inject_css('https://example.com/style.css'),
),
)
assert page
result = page.build()
assert result


def test_inject_js_head():
page = t.html(
t.body(
inject_js_head('https://example.com/script.js')
),
)
assert page
result = page.build()
assert result
assert 'https://example.com/script.js' in result


def test_inject_js_footer():
page = t.html(
t.body(
inject_js_footer('https://example.com/script.js'),
),
)
assert page
result = page.build()
assert result
assert 'https://example.com/script.js' in result


def test_inject_js_footer_nobody():
page = t.html(
t.head(
inject_js_footer('https://example.com/script.js'),
),
)
assert page
result = page.build()
assert result
9 changes: 7 additions & 2 deletions tests/test_tags.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@


def test_html():
r = t.html('Hello')
r
r = t.p('Hello')
assert r


def test_class_arg():
r = t.p('Hello', class_='important')
assert r


def test_page():
Expand Down

0 comments on commit 068b9b2

Please sign in to comment.