SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit f9379ec0 authored by Jorran de Wit's avatar Jorran de Wit
Browse files

Add test paragraph to readme

parent 21058657
No related branches found
No related tags found
No related merge requests found
......@@ -163,3 +163,30 @@ To build the documentation, run:
```
After this, generated documentation should be available in `docs/_build/html`.
## Writing tests
It is recommended, when writing tests, to use the `ContributorFactory` located in `scipost.factories`. This will automatically generate a related user with Registered Contributor membership. You may probably need to use the fixture list `["permissions", "groups"]` in your tests make sure the permissions groups are working properly.
It is recommended, when writing tests for new models, to make use of ModelFactories instead of fixtures to prevent issues with altering fields in the model later on.
A basic example of a test might look like:
```shell
from django.contrib.auth.models import Group
from django.test import TestCase
from scipost.factories import ContributorFactory
class VetCommentaryRequestsTest(TestCase):
fixtures = ['groups', 'permissions']
def setUp(self):
self.contributor = ContributorFactory(user__password='test123') # The default password is `adm1n`
def test_example_test(self):
group = Group.objects.get(name="Vetting Editors")
self.contributor.user.groups.add(group) # Assign user membership to an extra group
self.client.login(username=self.contributor.user.username, password='test123')
# Write your tests here
```
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment