mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-04 09:59:18 +02:00
Fixed #54: Now use pytest everywhere \o/
This commit is contained in:
parent
a7758395ee
commit
099cdfa99c
65 changed files with 1466 additions and 1467 deletions
42
api/tests/conftest.py
Normal file
42
api/tests/conftest.py
Normal file
|
@ -0,0 +1,42 @@
|
|||
import tempfile
|
||||
import shutil
|
||||
import pytest
|
||||
|
||||
|
||||
@pytest.fixture(scope="session", autouse=True)
|
||||
def factories_autodiscover():
|
||||
from django.apps import apps
|
||||
from funkwhale_api import factories
|
||||
app_names = [app.name for app in apps.app_configs.values()]
|
||||
factories.registry.autodiscover(app_names)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def factories(db):
|
||||
from funkwhale_api import factories
|
||||
yield factories.registry
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def tmpdir():
|
||||
d = tempfile.mkdtemp()
|
||||
yield d
|
||||
shutil.rmtree(d)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def logged_in_client(db, factories, client):
|
||||
user = factories['users.User']()
|
||||
assert client.login(username=user.username, password='test')
|
||||
setattr(client, 'user', user)
|
||||
yield client
|
||||
delattr(client, 'user')
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def superuser_client(db, factories, client):
|
||||
user = factories['users.SuperUser']()
|
||||
assert client.login(username=user.username, password='test')
|
||||
setattr(client, 'user', user)
|
||||
yield client
|
||||
delattr(client, 'user')
|
Loading…
Add table
Add a link
Reference in a new issue