1from django.contrib.auth.models import User, Group
2from testapp.models import Book
3
4import testapp.rules  # to register rules
5
6
7ISBN = '978-1-4302-1936-1'
8
9
10class TestData:
11    @classmethod
12    def setUpTestData(cls):
13        adrian = User.objects.create_user(
14            'adrian',
15            password='secr3t',
16            is_superuser=True,
17            is_staff=True)
18
19        martin = User.objects.create_user(
20            'martin',
21            password='secr3t',
22            is_staff=True)
23
24        editors = Group.objects.create(name='editors')
25        martin.groups.add(editors)
26
27        Book.objects.create(
28            isbn=ISBN,
29            title='The Definitive Guide to Django',
30            author=adrian)
31