mirror of
https://github.com/haiwen/seahub.git
synced 2025-08-19 07:27:56 +00:00
[tests] Add unittest for seahub
This commit is contained in:
parent
7bbd336d29
commit
b8764f4f21
@ -1,2 +1,3 @@
|
|||||||
[pytest]
|
[pytest]
|
||||||
addopts = -s -v
|
addopts = -s -v
|
||||||
|
DJANGO_SETTINGS_MODULE=seahub.settings
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
selenium==2.42.1
|
selenium==2.42.1
|
||||||
requests==2.3.0
|
requests==2.3.0
|
||||||
pytest
|
pytest
|
||||||
|
pytest-django==2.8.0
|
||||||
|
0
tests/seahub/__init__.py
Normal file
0
tests/seahub/__init__.py
Normal file
25
tests/seahub/test_accounts.py
Normal file
25
tests/seahub/test_accounts.py
Normal 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.'
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user