-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathconftest.py
More file actions
38 lines (26 loc) · 821 Bytes
/
conftest.py
File metadata and controls
38 lines (26 loc) · 821 Bytes
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
from unittest.mock import patch
import factory
import pytest
from django.contrib.sites.models import Site
from django_recaptcha.client import RecaptchaResponse
pytest_plugins = [
'users.tests.fixtures',
'warriors.tests.fixtures',
]
@pytest.fixture
def mocked_recaptcha(request):
is_valid = getattr(request, 'param', True)
with patch('django_recaptcha.fields.client.submit') as mocked_submit:
mocked_submit.return_value = RecaptchaResponse(is_valid=is_valid)
yield mocked_submit
@pytest.fixture
def user_client(client, user):
client.force_login(user)
return client
class SiteFactory(factory.django.DjangoModelFactory):
class Meta:
model = Site
domain = factory.Sequence(lambda n: f'n{n}.example.com')
@pytest.fixture
def site():
return SiteFactory()