|
1 | 1 | """Configure pytest for the tests module.""" |
2 | 2 |
|
3 | | -import io |
4 | 3 | import uuid |
5 | | -from pathlib import Path |
6 | 4 | from unittest import mock |
7 | 5 |
|
8 | 6 | import pytest |
9 | | -from faker import Faker |
10 | | -from PIL import Image |
11 | 7 | from rest_framework.test import APIRequestFactory |
12 | 8 |
|
13 | 9 | from django.conf import settings |
14 | | -from django.core.files.uploadedfile import SimpleUploadedFile |
15 | 10 |
|
16 | 11 | from app.settings import TenantTypes |
17 | 12 | from oauth.models import User |
@@ -142,44 +137,27 @@ def auth_user(client, factories, test_username, test_password): |
142 | 137 |
|
143 | 138 |
|
144 | 139 | @pytest.fixture |
145 | | -def admin_user(factories): |
| 140 | +def admin_user(factories, test_username, test_password): |
146 | 141 | """Inject a staff user.""" |
147 | | - return factories.users.create(is_staff=True) |
| 142 | + return factories.users.create( |
| 143 | + username=test_username, |
| 144 | + password=test_password, |
| 145 | + is_staff=True, |
| 146 | + ) |
148 | 147 |
|
149 | 148 |
|
150 | 149 | @pytest.fixture |
151 | | -def superuser(factories): |
| 150 | +def superuser(factories, test_username, test_password): |
152 | 151 | """Inject a superuser.""" |
153 | | - return factories.users.create(is_superuser=True) |
| 152 | + return factories.users.create( |
| 153 | + username=test_username, |
| 154 | + password=test_password, |
| 155 | + is_staff=True, |
| 156 | + is_superuser=True, |
| 157 | + ) |
154 | 158 |
|
155 | 159 |
|
156 | 160 | @pytest.fixture |
157 | 161 | def bare_agent(factories): |
158 | 162 | """Inject a **Bare Agent**, ie. a person without a related user.""" |
159 | 163 | return factories.people(bare_agent=True) |
160 | | - |
161 | | - |
162 | | -@pytest.fixture |
163 | | -def team_member(factories): |
164 | | - """Inject a regular team member.""" |
165 | | - return factories.team_members.create() |
166 | | - |
167 | | - |
168 | | -@pytest.fixture |
169 | | -def avatar_image(): |
170 | | - """Inject an avatar image.""" |
171 | | - fake = Faker() |
172 | | - filename = fake.file_name(category='image', extension='png') |
173 | | - |
174 | | - with io.BytesIO() as buffer: |
175 | | - image = Image.new('RGBA', size=(50, 50), color=(155, 0, 0)) |
176 | | - image.save(buffer, 'png') |
177 | | - buffer.name = filename |
178 | | - buffer.seek(0) |
179 | | - image_file = SimpleUploadedFile(name=filename, content=buffer.getvalue(), content_type='image/png') |
180 | | - |
181 | | - # Manifest handling and filename collisions can cause a non-deterministic |
182 | | - # hash to be added to the filename, so we retrieve the *actual* name next. |
183 | | - filename = Path(image_file.name).name |
184 | | - |
185 | | - return image_file |
0 commit comments