Fixed #54: Now use pytest everywhere \o/

This commit is contained in:
Eliot Berriot 2017-12-24 19:15:21 +01:00
parent a7758395ee
commit 099cdfa99c
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
65 changed files with 1466 additions and 1467 deletions

42
api/tests/conftest.py Normal file
View 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')