Merge pull request #37 from ikame/pytest

New tests skeleton and examples using pytest
remotes/origin/enhancement/email-actions
Andrey Antukh 2014-04-29 14:32:35 +02:00
commit 9d448924a7
6 changed files with 44 additions and 0 deletions

2
pytest.ini Normal file
View File

@ -0,0 +1,2 @@
[pytest]
DJANGO_SETTINGS_MODULE = settings.testing

6
requirements-devel.txt Normal file
View File

@ -0,0 +1,6 @@
-r requirements.txt
factory-boy==2.3.1
py==1.4.20
pytest==2.5.2
pytest-django==2.6.1

0
tests/__init__.py Normal file
View File

0
tests/auth/__init__.py Normal file
View File

23
tests/auth/test_api.py Normal file
View File

@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
import pytest
from unittest import mock
from rest_framework.reverse import reverse
from ..factories import DomainFactory
pytestmark = pytest.mark.django_db
def setup_module(module):
module.patcher = mock.patch("taiga.domains.base.get_default_domain", DomainFactory.build)
module.patcher.start()
def teardown_module(module):
module.patcher.stop()
def test_respond_400_if_credentials_are_invalid(client):
response = client.post(reverse("auth-list"), {"username": "john", "password": "smith"})
assert response.status_code == 400

13
tests/factories.py Normal file
View File

@ -0,0 +1,13 @@
# -*- coding: utf-8 -*-
import factory
from taiga.domains import models
class DomainFactory(factory.DjangoModelFactory):
FACTORY_FOR = models.Domain
public_register = False
scheme = None
name = "localhost"
domain = "localhost"