-
Notifications
You must be signed in to change notification settings - Fork 9
/
conftest.py
60 lines (40 loc) · 1.48 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
# global personal configuration of pytest
import pytest
from django.contrib.sites.shortcuts import get_current_site
from django.core.management import call_command
from model_bakery import baker
from recoco.apps.projects.models import Project
# -- Global Fixtures
@pytest.fixture(scope="session", autouse=True)
def setup_db(django_db_setup, django_db_blocker):
with django_db_blocker.unblock():
call_command("update_permissions")
# -- Project Fixtures
@pytest.fixture
def make_project(request):
def _make_project(site=None, status="READY", **kwargs):
default_data = {
"description": "Super description",
"location": "SomeWhere",
}
default_data.update(**kwargs)
project = baker.make(Project, **default_data)
if not site:
site = get_current_site(request)
project.project_sites.create(site=site, status=status, is_origin=True)
return project
return _make_project
@pytest.fixture
def project_draft(request, make_project):
"""Create a project on the current site with status PROPOSED"""
yield make_project(status="DRAFT")
@pytest.fixture
def project_proposed(request, make_project):
"""Create a project on the current site with status PROPOSED"""
yield make_project(status="PROPOSED")
@pytest.fixture
def project(request, make_project):
"""Create a project on the current site with status READY"""
yield make_project(status="READY")
project_ready = project
# eof