|
|
## When you want to work on a page
|
|
|
|
|
|
Design v3 migration is done on the `v3` branch. Migration tasks are defined in issues, grouped by page. When you want to work on a given issue:
|
|
|
|
|
|
1. Assign the issue to yourself
|
|
|
2. Do some work, write some tests, push to the `v3` branch
|
|
|
3. Check the appropriate checkboxes in the issue
|
|
|
4. 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).
|
|
|
|
|
|
## Writing tests
|
|
|
|
|
|
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:
|
|
|
|
|
|
```python
|
|
|
from django import test
|
|
|
from responsediff.test importt 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). You can also omit the selector, in which case the whole response (ie. the whole html page) will be tested -- don't overuse this, because then page header changes will make many tests fail.
|
|
|
|
|
|
Please also ensure you include database query tests to prevent performance regressions. Use `TestCase.assertNumQueries` and *specify which queries are expected* as follows:
|
|
|
|
|
|
|
|
|
```python
|
|
|
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)
|
|
|
``` |