testfunc/test/windmill/test_connexion.py
author Sylvain Thénault <sylvain.thenault@logilab.fr>
Thu, 21 Jul 2011 14:20:45 +0200
branchstable
changeset 7682 07b592a62be3
parent 7363 2293c49b290a
child 8696 0bb18407c053
permissions -rw-r--r--
[c-c db-check] drop some deprecation warning
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     1
from cubicweb.devtools import DEFAULT_SOURCES
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     2
LOGIN, PASSWORD = DEFAULT_SOURCES['admin'].values()
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     3
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     4
# Generated by the windmill services transformer
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     5
from windmill.authoring import WindmillTestClient
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     6
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     7
def test_connect():
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     8
    client = WindmillTestClient(__name__)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
     9
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    10
    client.open(url=u'/')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    11
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    12
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    13
    client.type(text=LOGIN, id=u'__login')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    14
    client.type(text=PASSWORD, id=u'__password')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    15
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    16
    client.execJS(js=u"$('#loginForm').submit()")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    17
    client.waits.forPageLoad(timeout=u'20000')
6695
b714521ac66d [windmill tests] use extra timeouts, else we get failure simplu because we didn't wait enough
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 6034
diff changeset
    18
    client.waits.sleep(milliseconds=u'5000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    19
    client.asserts.assertJS(js=u'$(\'.message\').text() == "welcome %s !"' % LOGIN)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    20
    client.open(url=u'/logout')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    21
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    22
    client.open(url=u'/')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    23
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    24
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    25
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    26
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    27
def test_wrong_connect():
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    28
    client = WindmillTestClient(__name__)
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    29
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    30
    client.open(url=u'/')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    31
    # XXX windmill wants to use its proxy internally on 403 :-(
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    32
    #client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    33
    #client.type(text=LOGIN, id=u'__login')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    34
    #client.type(text=u'novalidpassword', id=u'__password')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    35
    #client.click(value=u'log in')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    36
    client.open(url=u'/?__login=user&__password=nopassword')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    37
    client.waits.forPageLoad(timeout=u'20000')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    38
    client.asserts.assertTextIn(validator=u'authentication failure', id=u'loginBox')
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    39
    client.open(url=u'/')
6034
5e8076eb8ec7 tests: use larger timeouts in windmill tests
Julien Jehannet <julien.jehannet@logilab.fr>
parents: 5675
diff changeset
    40
    client.waits.forPageLoad(timeout=u'20000')
5675
4535f8e57580 [web test] add basic windmill tests and documentation
Julien Jehannet <julien.jehannet@logilab.fr>
parents:
diff changeset
    41
    client.asserts.assertJS(js=u"$('#loginForm').is(':visible')")