-
Notifications
You must be signed in to change notification settings - Fork 2
Guidelines for design v3 migration
Branch v3
is continuously deployed there: https://v3-memopol.rhcloud.com/ (as long as no tests fail)
The design v3 mockup: https://v3-memopol.rhcloud.com/static/collected/reference/design-v3/index.html
Design v3 migration is done on the v3
branch. Migration tasks are defined in issues (#136 to #142), grouped by page.
When you want to work on a given issue:
- Assign the issue to yourself
- Do some work, write some tests, push to the
v3
branch - Check the appropriate checkboxes in the issue
- Un-assign the issue
This will hopefully prevent most conflicts. Note that you don't have to clear an issue completely at once! You can just clear a few checkboxes and come back later (or let others do the rest).
Every feature and every bit of a page should be tested when it's pushed to the repository. You may TDD if you like, or at least write regression tests when you're done. For the latter, django-responsediff
will help. You can write tests as follows:
from django import test
from responsediff.test import ResponseDiffTestMixin
class MyPageTest(ResponseDiffTestMixin, test.TestCase):
url = '/representatives/john-doe/'
def selector_test(self, selector):
self.assertResponseDiffEmpty(test.Client().get(self.url), selector)
def test_name(self):
self.selector_test('#name')
def test_mandates(self):
self.selector_test('table.mandates tr')
Each call to assertResponseDiffEmpty
with a selector will extract all elements that match the selector, and compare them to a fixture (it will create the fixture and fail on first run).
Here are some guidelines for testing templates:
- Don't test for "static" HTML (ie. HTML that is rendered straight from templates).
- Do test for dynamically-generated HTML, eg. for loops
- Avoid writing tests without selectors (ie. full-page tests). Those will all fail as soon as a header change is made (or as soon as a collected static resource, such as CSS or JS, changes).
- Also ensure you include database query tests to prevent performance regressions. Use
TestCase.assertNumQueries
and specify which queries are expected as follows:
from django import test
class MyPageTest(test.TestCase):
url = '/representatives/john-doe/'
def test_queries(self):
with self.assertNumQueries(3):
"""
- 1 query for the representative
- 1 query for related websites
- 1 query for related mandates
"""
test.Client().get(self.url)