IP = '127.0.0.1'
PORT = 8000
SITE = 'http://%s:%s' % (IP, PORT)
class TwillMock(object):
def setup(self):
'''
- setup twill virtual web server
'''
from django.core.servers.basehttp import AdminMediaHandler
from django.core.handlers.wsgi import WSGIHandler
from wsgi_intercept import add_wsgi_intercept
app = AdminMediaHandler(WSGIHandler())
add_wsgi_intercept(IP, PORT, lambda: app)
class NotATestTwillRegistration(TwillMock):
def test_login_success(self, username='test', password='test'):
go(SITE + '/accounts/login/')
code(200)
formvalue(1, 'username', username)
formvalue(1, 'password', password)
submit()
url(SITE + '/accounts/profile/')
code(200)
def test_incorrect_password(self):
go(SITE + '/accounts/login/')
code(200)
formvalue(1, 'username', 'test')
formvalue(1, 'password', 'OMG! I have forgotten it!')
submit()
url(SITE + '/accounts/login/')
find('<ul class="errorlist">')
code(200)
P.S. Возможно тема уже тут обсуждалась, но не нашёл.