parent
665be60d15
commit
bb4c3cf989
6 changed files with 38 additions and 1 deletions
@ -0,0 +1,12 @@ |
||||
# -*- coding: utf-8 -*- |
||||
# flake8: noqa |
||||
|
||||
""" |
||||
The `compat` module provides support for backwards compatibility with older |
||||
versions of django/python, and compatibility wrappers around optional packages. |
||||
""" |
||||
|
||||
try: |
||||
from mock import patch, Mock |
||||
except ImportError: |
||||
from unittest.mock import patch, Mock |
||||
@ -1,4 +1,5 @@ |
||||
# -*- coding: utf-8 -*- |
||||
pytest_plugins = [ |
||||
'src.tests.fixtures.models' |
||||
'src.tests.fixtures.auth', |
||||
'src.tests.fixtures.common' |
||||
] |
||||
|
||||
@ -0,0 +1,15 @@ |
||||
# -*- coding: utf-8 -*- |
||||
import pytest |
||||
|
||||
from tests._compat import patch, Mock |
||||
|
||||
|
||||
@pytest.fixture |
||||
def mocked_request(request): |
||||
""" |
||||
A test fixture to mock the request |
||||
""" |
||||
mock = patch('requests.get', Mock()) |
||||
mock.start() |
||||
request.addfinalizer(mock.stop) |
||||
return mock.new |
||||
@ -0,0 +1,8 @@ |
||||
# -*- coding: utf-8 -*- |
||||
|
||||
from commons import utils |
||||
|
||||
|
||||
def test_utils(mocked_request): |
||||
url = utils.get_site_url(mocked_request) |
||||
assert len(url.split('//')) == 2 |
||||
Loading…
Reference in new issue