You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
58 lines
1.3 KiB
58 lines
1.3 KiB
import os
|
|
import shutil
|
|
|
|
import pytest
|
|
|
|
from tests.client import BetterAPIClient
|
|
|
|
pytest_plugins = [
|
|
'access.tests.fixtures',
|
|
'finance.tests.fixtures',
|
|
'courses.tests.fixtures'
|
|
]
|
|
|
|
|
|
def pytest_sessionfinish(session, exitstatus):
|
|
""" whole test run finishes. """
|
|
print('pytest finish: cleanup')
|
|
if os.path.exists('media_qa'):
|
|
shutil.rmtree('media_qa')
|
|
|
|
|
|
@pytest.fixture
|
|
def api_client():
|
|
"""Anonymous client for REST API."""
|
|
client = BetterAPIClient()
|
|
return client
|
|
|
|
|
|
@pytest.fixture
|
|
def admin_client(admin):
|
|
"""Authorized as admin(superuser) client for REST API."""
|
|
client = BetterAPIClient()
|
|
client.force_authenticate(user=admin)
|
|
return client
|
|
|
|
|
|
@pytest.fixture
|
|
def student_client(student):
|
|
"""Authorized as student client for REST API."""
|
|
client = BetterAPIClient()
|
|
client.force_authenticate(user=student)
|
|
return client
|
|
|
|
|
|
@pytest.fixture
|
|
def manager_client(manager):
|
|
"""Authorized as manager client for REST API."""
|
|
client = BetterAPIClient()
|
|
client.force_authenticate(user=manager)
|
|
return client
|
|
|
|
|
|
@pytest.fixture
|
|
def lead_manager_client(lead_manager):
|
|
"""Authorized as lead manager client for REST API."""
|
|
client = BetterAPIClient()
|
|
client.force_authenticate(user=lead_manager)
|
|
return client
|
|
|