Skip to content

Commit

Permalink
[Fixes #1555] Added test for markup errors + mini fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kardan committed May 15, 2015
1 parent 8af3c9e commit 25255bb
Show file tree
Hide file tree
Showing 10 changed files with 55 additions and 11 deletions.
7 changes: 7 additions & 0 deletions akvo/rsr/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# -*- coding: utf-8 -*-

"""Akvo RSR is covered by the GNU Affero General Public License.
See more details in the license.txt file located at the root folder of the Akvo RSR module.
For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
"""
9 changes: 7 additions & 2 deletions akvo/rsr/tests/pages/test_not_found.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from django.conf import settings
from django.test import Client, TestCase
from ..utils import contains_template_errors


class NotFoundPageTest(TestCase):
Expand All @@ -17,8 +18,12 @@ class NotFoundPageTest(TestCase):
def setUp(self):
"""Setup."""
self.c = Client(HTTP_HOST=settings.RSR_DOMAIN)
self.resp = self.c.get('/does-not-exist')

def test_not_found(self):
"""."""
response = self.c.get('/does-not-exist')
self.assertEqual(response.status_code, 404)
self.assertEqual(self.resp.status_code, 404)

def test_template_markup(self):
"""Check for common template errors."""
self.assertFalse(contains_template_errors(self.resp.content))
9 changes: 7 additions & 2 deletions akvo/rsr/tests/pages/test_organisations_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from django.conf import settings
from django.test import Client, TestCase
from ..utils import contains_template_errors


class PingTest(TestCase):
Expand All @@ -17,8 +18,12 @@ class PingTest(TestCase):
def setUp(self):
"""Setup."""
self.c = Client(HTTP_HOST=settings.RSR_DOMAIN)
self.resp = self.c.get('/organisations/')

def test_ping(self):
"""Ping /organisations/."""
response = self.c.get('/organisations/')
self.assertEqual(response.status_code, 200)
self.assertEqual(self.resp.status_code, 200)

def test_template_markup(self):
"""Check for common template errors."""
self.assertFalse(contains_template_errors(self.resp.content))
9 changes: 7 additions & 2 deletions akvo/rsr/tests/pages/test_project_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from django.conf import settings
from django.test import Client, TestCase
from ..utils import contains_template_errors


class PingTest(TestCase):
Expand All @@ -17,8 +18,12 @@ class PingTest(TestCase):
def setUp(self):
"""Setup."""
self.c = Client(HTTP_HOST=settings.RSR_DOMAIN)
self.resp = self.c.get('/projects/')

def test_ping(self):
"""Ping /projects/."""
response = self.c.get('/projects/')
self.assertEqual(response.status_code, 200)
self.assertEqual(self.resp.status_code, 200)

def test_template_markup(self):
"""Check for common template errors."""
self.assertFalse(contains_template_errors(self.resp.content))
9 changes: 7 additions & 2 deletions akvo/rsr/tests/pages/test_updates_dir.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from django.conf import settings
from django.test import Client, TestCase
from ..utils import contains_template_errors


class PingTest(TestCase):
Expand All @@ -17,8 +18,12 @@ class PingTest(TestCase):
def setUp(self):
"""Setup."""
self.c = Client(HTTP_HOST=settings.RSR_DOMAIN)
self.resp = self.c.get('/updates/')

def test_ping(self):
"""Ping /updates/."""
response = self.c.get('/updates/')
self.assertEqual(response.status_code, 200)
self.assertEqual(self.resp.status_code, 200)

def test_template_markup(self):
"""Check for common template errors."""
self.assertFalse(contains_template_errors(self.resp.content))
6 changes: 6 additions & 0 deletions akvo/rsr/tests/pages/test_widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from django.conf import settings
from django.test import Client, TestCase
from akvo.rsr.models import Project, Organisation
from ..utils import contains_template_errors


class PingWidgetsTest(TestCase):
Expand All @@ -26,27 +27,32 @@ def test_narrow(self):
p = Project.objects.get(title="Test Project")
response = self.c.get('/widgets/project-narrow/{}/'.format(p.id))
self.assertEqual(response.status_code, 200)
self.assertFalse(contains_template_errors(response.content))

def test_cobranded_banner(self):
"""Ping /widgets/cobranded-banner."""
p = Project.objects.get(title="Test Project")
response = self.c.get('/widgets/cobranded-banner/{}/'.format(p.id))
self.assertEqual(response.status_code, 200)
self.assertFalse(contains_template_errors(response.content))

def test_project_small(self):
"""Ping /widgets/project-small."""
p = Project.objects.get(title="Test Project")
response = self.c.get('/widgets/project-small/{}/'.format(p.id))
self.assertEqual(response.status_code, 200)
self.assertFalse(contains_template_errors(response.content))

def test_project_map(self):
"""Ping /widgets/projects/map."""
o = Organisation.objects.get(name="Partner1")
response = self.c.get('/widgets/projects/map/?organisation_id={}'.format(o.id))
self.assertEqual(response.status_code, 200)
self.assertFalse(contains_template_errors(response.content))

def test_project_list(self):
"""Ping /widgets/projects/list."""
o = Organisation.objects.get(name="Partner1")
response = self.c.get('/widgets/projects/list/?organisation_id={}'.format(o.id))
self.assertEqual(response.status_code, 200)
self.assertFalse(contains_template_errors(response.content))
13 changes: 13 additions & 0 deletions akvo/rsr/tests/utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-

"""Akvo RSR is covered by the GNU Affero General Public License.
See more details in the license.txt file located at the root folder of the Akvo RSR module.
For additional details on the GNU license please see < http://www.gnu.org/licenses/agpl.html >.
"""


def contains_template_errors(markup):
"""Itterate over the markup looking for common errors."""
common_errors = ['{%', '%}', '{{', '}}']
return any(x in markup for x in common_errors)
2 changes: 1 addition & 1 deletion akvo/templates/organisation_directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</div>
</section>
<div id="wrapper">
<aside id="sidebar-wrapper" class="{ show_filters }}">
<aside id="sidebar-wrapper" class="{{ show_filters }}">
<div id="filter" class="">
<div>
<div class="btn-group">
Expand Down
1 change: 0 additions & 1 deletion akvo/templates/project_directory.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
{% load i18n maps rsr_utils thumbnail humanize bootstrap3 compressed %}
{% block title %}{% trans 'Projects' %}{% endblock %}
{% block maincontent %}

<section id="map" class="touch-navbar">
{% coll_map map_projects '100%' '100%' %}
</section>
Expand Down
1 change: 0 additions & 1 deletion akvo/templates/widgets/project_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
{{block.super}}
{% compressed_css 'widget_project_list' %}
{% endblock style %}

{% block body %}
<section id="container" class="projectList {{style}} rsrWidget floats-in">
<!-- DEVICES TABLE-->
Expand Down

0 comments on commit 25255bb

Please sign in to comment.