-
-
Notifications
You must be signed in to change notification settings - Fork 128
/
conftest.py
82 lines (58 loc) · 1.92 KB
/
conftest.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import pytest
from django.contrib.auth.models import Group
from django.core.management import call_command
from devel.models import UserProfile
from main.models import Repo
USERNAME = 'joeuser'
FIRSTNAME = 'Joe'
LASTNAME = 'User'
EMAIL = 'user1@example.com'
@pytest.fixture
def arches(db):
# TODO: create Arch object
call_command('loaddata', 'main/fixtures/arches.json')
@pytest.fixture
def repos(arches):
# TODO: create Repo object
call_command('loaddata', 'main/fixtures/repos.json')
@pytest.fixture
def package(db, arches, repos):
# TODO: convert to create_package with standard parameters
call_command('loaddata', 'main/fixtures/package.json')
@pytest.fixture
def groups(db):
call_command('loaddata', 'main/fixtures/groups.json')
@pytest.fixture
def staff_groups(db):
call_command('loaddata', 'devel/fixtures/staff_groups.json')
@pytest.fixture
def user(django_user_model):
user = django_user_model.objects.create_user(username=USERNAME, password=USERNAME, email=EMAIL)
yield user
user.delete()
@pytest.fixture
def userprofile(user):
profile = UserProfile.objects.create(user=user,
public_email=f'{user.username}@archlinux.org')
yield profile
profile.delete()
@pytest.fixture
def developer(user, userprofile, repos, groups):
user.groups.add(Group.objects.get(name='Developers'))
userprofile.allowed_repos.add(Repo.objects.get(name='Core'))
return user
@pytest.fixture
def developer_client(client, developer, userprofile, groups):
client.login(username=USERNAME, password=USERNAME)
return client
@pytest.fixture
def denylist(db):
# TODO: create Denylist object
call_command('loaddata', 'main/fixtures/denylist.json')
@pytest.fixture(autouse=True)
def use_dummy_cache_backend(settings):
settings.CACHES = {
"default": {
"BACKEND": "django.core.cache.backends.dummy.DummyCache",
}
}