Skip to content

Commit 26570c7

Browse files
committed
tests: Add a basic login test
1 parent 4dfba41 commit 26570c7

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

tests/__init__.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def difffile(expect, filename):
2727

2828

2929
def clicomm(argv, bzinstance, returnmain=False, printcliout=False,
30-
stdin=None):
30+
stdin=None, expectfail=False):
3131
"""
3232
Run bin/bugzilla.main() directly with passed argv
3333
"""
@@ -64,9 +64,13 @@ def clicomm(argv, bzinstance, returnmain=False, printcliout=False,
6464
if outt.endswith("\n"):
6565
outt = outt[:-1]
6666

67-
if ret != 0:
67+
if ret != 0 and not expectfail:
6868
raise RuntimeError("Command failed with %d\ncmd=%s\nout=%s" %
6969
(ret, argv, outt))
70+
elif ret == 0 and expectfail:
71+
raise RuntimeError("Command succeeded but we expected success\n"
72+
"ret=%d\ncmd=%s\nout=%s" % (ret, argv, outt))
73+
7074
if returnmain:
7175
return mainout
7276
return outt

tests/rw_functional.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -449,3 +449,13 @@ def test9Whiteboards(self):
449449
self.assertEquals(bug.qa_whiteboard, "")
450450
self.assertEquals(bug.devel_whiteboard, "")
451451
self.assertEquals(bug.internal_whiteboard, "")
452+
453+
def test10Login(self):
454+
"""
455+
Failed login test, gives us a bit more coverage
456+
"""
457+
ret = tests.clicomm("bugzilla --bugzilla %s "
458+
459+
"--password foobar login" % self.url, None,
460+
expectfail=True)
461+
self.assertTrue("Logging in... failed." in ret)

0 commit comments

Comments
 (0)