1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-04-27 11:01:14 +00:00

[tests] Add unittest for seahub

This commit is contained in:
zhengxie 2015-03-18 18:14:59 +08:00
parent 7bbd336d29
commit b8764f4f21
4 changed files with 28 additions and 1 deletions

View File

@ -1,2 +1,3 @@
[pytest]
addopts = -s -v
addopts = -s -v
DJANGO_SETTINGS_MODULE=seahub.settings

View File

@ -1,3 +1,4 @@
selenium==2.42.1
requests==2.3.0
pytest
pytest-django==2.8.0

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

View File

@ -0,0 +1,25 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
from tests.common.common import BASE_URL, USERNAME, PASSWORD
LOGIN_URL = reverse('auth_login')
class LoginTest(TestCase):
def test_renders_correct_template(self):
resp = self.client.get(LOGIN_URL)
assert resp.status_code == 200
self.assertTemplateUsed(resp, 'registration/login.html')
def test_invalid_password(self):
# load it once for test cookie
self.client.get(LOGIN_URL)
resp = self.client.post(LOGIN_URL, {
'username': USERNAME,
'password': 'fakepasswd',
})
assert resp.status_code == 200
assert resp.context['form'].errors['__all__'] == [
u'Please enter a correct username and password. Note that both fields are case-sensitive.'
]