本文整理汇总了Python中tests.clicomm函数的典型用法代码示例。如果您正苦于以下问题:Python clicomm函数的具体用法?Python clicomm怎么用?Python clicomm使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了clicomm函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test03NewBugBasic
def test03NewBugBasic(self):
"""
Create a bug with minimal amount of fields, then close it
"""
bz = self.bzclass(url=self.url)
component = "python-bugzilla"
version = "rawhide"
summary = ("python-bugzilla test basic bug %s" %
datetime.datetime.today())
newout = tests.clicomm("bugzilla new "
"--product Fedora --component %s --version %s "
"--summary \"%s\" "
"--comment \"Test bug from the python-bugzilla test suite\" "
"--outputformat \"%%{bug_id}\"" %
(component, version, summary), bz)
self.assertTrue(len(newout.splitlines()) == 3)
bugid = int(newout.splitlines()[2])
bug = bz.getbug(bugid)
print("\nCreated bugid: %s" % bugid)
# Verify hasattr works
self.assertTrue(hasattr(bug, "id"))
self.assertTrue(hasattr(bug, "bug_id"))
self.assertEqual(bug.component, component)
self.assertEqual(bug.version, version)
self.assertEqual(bug.summary, summary)
# Close the bug
tests.clicomm("bugzilla modify --close NOTABUG %s" % bugid, bz)
bug.refresh()
self.assertEqual(bug.status, "CLOSED")
self.assertEqual(bug.resolution, "NOTABUG")
示例2: test4NewBugAllFields
def test4NewBugAllFields(self):
"""
Create a bug using all 'new' fields, check some values, close it
"""
bz = self.bzclass(url=self.url, cookiefile=cf, tokenfile=tf)
summary = ("python-bugzilla test manyfields bug %s" %
datetime.datetime.today())
url = "http://example.com"
osval = "Windows"
cc = "[email protected]"
blocked = "461686,461687"
dependson = "427301"
comment = "Test bug from python-bugzilla test suite"
sub_component = "Command-line tools (RHEL6)"
alias = "pybz-%s" % datetime.datetime.today().strftime("%s")
newout = tests.clicomm("bugzilla new "
"--product 'Red Hat Enterprise Linux 6' --version 6.0 "
"--component lvm2 --sub-component '%s' "
"--summary \"%s\" "
"--comment \"%s\" "
"--url %s --severity Urgent --priority Low --os %s "
"--arch ppc --cc %s --blocked %s --dependson %s "
"--alias %s "
"--outputformat \"%%{bug_id}\"" %
(sub_component, summary, comment, url,
osval, cc, blocked, dependson, alias), bz)
self.assertTrue(len(newout.splitlines()) == 3)
bugid = int(newout.splitlines()[2])
bug = bz.getbug(bugid)
print("\nCreated bugid: %s" % bugid)
self.assertEquals(bug.summary, summary)
self.assertEquals(bug.bug_file_loc, url)
self.assertEquals(bug.op_sys, osval)
self.assertEquals(bug.blocks, _split_int(blocked))
self.assertEquals(bug.depends_on, _split_int(dependson))
self.assertTrue(all([e in bug.cc for e in cc.split(",")]))
self.assertEquals(bug.longdescs[0]["text"], comment)
self.assertEquals(bug.sub_components, {"lvm2": [sub_component]})
self.assertEquals(bug.alias, [alias])
# Close the bug
# RHBZ makes it difficult to provide consistent semantics for
# 'alias' update:
# https://bugzilla.redhat.com/show_bug.cgi?id=1173114
# alias += "-closed"
tests.clicomm("bugzilla modify "
"--close WONTFIX %s " %
bugid, bz)
bug.refresh()
self.assertEquals(bug.status, "CLOSED")
self.assertEquals(bug.resolution, "WONTFIX")
self.assertEquals(bug.alias, [alias])
示例3: testPositionalArgs
def testPositionalArgs(self):
# Make sure cli correctly rejects ambiguous positional args
out = tests.clicomm("bugzilla login --xbadarg foo",
None, expectfail=True)
assert "unrecognized arguments: --xbadarg" in out
out = tests.clicomm("bugzilla modify 123456 --foobar --status NEW",
None, expectfail=True)
assert "unrecognized arguments: --foobar" in out
示例4: clicomm
def clicomm(self, argstr, expectexc=False, bz=None):
comm = "bugzilla " + argstr
if not bz:
bz = Bugzilla(url=self.url, use_creds=False)
if expectexc:
with pytest.raises(Exception):
tests.clicomm(comm, bz)
else:
return tests.clicomm(comm, bz)
示例5: test03NewBugBasic
def test03NewBugBasic(self):
"""
Create a bug with minimal amount of fields, then close it
"""
bz = self.bzclass(url=self.url)
bug = self._makebug(bz)
# Verify hasattr works
assert hasattr(bug, "id")
assert hasattr(bug, "bug_id")
# Close the bug
tests.clicomm("bugzilla modify --close NOTABUG %s" % bug.id, bz)
bug.refresh()
assert bug.status == "CLOSED"
assert bug.resolution == "NOTABUG"
示例6: testUnknownKeys
def testUnknownKeys(self):
"""
Make sure unknown key detection works
"""
# Prevent unfinished crate support from interfering
# pylint: disable=protected-access
# Ignore 'Access to protected member'
from scratchlivedb.scratchdb import _unknowns
_unknowns.unknowns = {}
# pylint: enable=protected-access
out = tests.clicomm("scratchlivedb-tool dump %s" % unknowndb)
assert "Unknown keys encountered: ['tzzz', 'uzzz', 'zzzz']" in out
out = tests.clicomm("scratchlivedb-tool --debug dump %s" % unknowndb)
assert "Unknown type for key 'zzzz'" in out
示例7: test10Login
def test10Login(self):
"""
Failed login test, gives us a bit more coverage
"""
# We overwrite getpass for testing
import getpass
def fakegetpass(prompt):
sys.stdout.write(prompt)
sys.stdout.flush()
return sys.stdin.readline()
oldgetpass = getpass.getpass
getpass.getpass = fakegetpass
try:
# Implied login with --username and --password
ret = tests.clicomm(
"bugzilla --bugzilla %s " "--user [email protected] " "--password foobar query -b 123456" % self.url,
None,
expectfail=True,
)
self.assertTrue("Login failed: " in ret)
# 'login' with explicit options
ret = tests.clicomm(
"bugzilla --bugzilla %s " "--user [email protected] " "--password foobar login" % self.url,
None,
expectfail=True,
)
self.assertTrue("Login failed: " in ret)
# 'login' with positional options
ret = tests.clicomm(
"bugzilla --bugzilla %s " "login [email protected] foobar" % self.url, None, expectfail=True
)
self.assertTrue("Login failed: " in ret)
# bare 'login'
stdinstr = "[email protected]\n\rfoobar\n\r"
ret = tests.clicomm("bugzilla --bugzilla %s login" % self.url, None, expectfail=True, stdinstr=stdinstr)
self.assertTrue("Bugzilla Username:" in ret)
self.assertTrue("Bugzilla Password:" in ret)
self.assertTrue("Login failed: " in ret)
finally:
getpass.getpass = oldgetpass
示例8: test06ModifyEmails
def test06ModifyEmails(self):
"""
Modify cc, assignee, qa_contact for existing bug
"""
bz = self.bzclass(url=self.url)
bugid = "663674"
cmd = "bugzilla modify %s " % bugid
bug = bz.getbug(bugid)
origcc = bug.cc
# Test CC list and reset it
email1 = "[email protected]"
email2 = "[email protected]"
bug.deletecc(origcc)
tests.clicomm(cmd + "--cc %s --cc %s" % (email1, email2), bz)
bug.addcc(email1)
bug.refresh()
self.assertTrue(email1 in bug.cc)
self.assertTrue(email2 in bug.cc)
self.assertEquals(len(bug.cc), 2)
tests.clicomm(cmd + "--cc=-%s" % email1, bz)
bug.refresh()
self.assertTrue(email1 not in bug.cc)
# Test assigned target
tests.clicomm(cmd + "--assignee %s" % email1, bz)
bug.refresh()
self.assertEquals(bug.assigned_to, email1)
# Test QA target
tests.clicomm(cmd + "--qa_contact %s" % email1, bz)
bug.refresh()
self.assertEquals(bug.qa_contact, email1)
# Reset values
bug.deletecc(bug.cc)
tests.clicomm(cmd + "--reset-qa-contact --reset-assignee", bz)
bug.refresh()
self.assertEquals(bug.cc, [])
self.assertEquals(bug.assigned_to, "[email protected]")
self.assertEquals(bug.qa_contact, "[email protected]")
示例9: clicomm
def clicomm(self, argstr, expectexc=False):
comm = "bugzilla " + argstr
bz = self.bzclass(url=self.url, cookiefile=None, tokenfile=None)
if expectexc:
self.assertRaises(Exception, tests.clicomm, comm, bz)
else:
return tests.clicomm(comm, bz)
示例10: testCertFail
def testCertFail(self):
# No public setup that I know of to test cert succeeds, so
# let's give it a bogus file and ensure it fails
badcert = os.path.join(os.path.dirname(__file__), "..", "README.md")
out = tests.clicomm(
"bugzilla --cert %s query --bug_id 123456" % badcert,
None, expectfail=True)
assert "PEM" in out
示例11: testFaults
def testFaults(self):
# Test special error wrappers in bugzilla/_cli.py
bzinstance = Bugzilla(self.url, use_creds=False)
out = tests.clicomm("bugzilla query --field=IDONTEXIST=FOO",
bzinstance, expectfail=True)
assert "Server error:" in out
out = tests.clicomm("bugzilla "
"--bugzilla https://example.com/xmlrpc.cgi "
"query --field=IDONTEXIST=FOO", None, expectfail=True)
assert "Connection lost/failed" in out
out = tests.clicomm("bugzilla "
"--bugzilla https://expired.badssl.com/ "
"query --bug_id 1234", None, expectfail=True)
assert "trust the remote server" in out
assert "--nosslverify" in out
示例12: clicomm
def clicomm(self, argstr, out):
comm = "bugzilla query --test-return-result " + argstr
if out is None:
self.assertRaises(RuntimeError, tests.clicomm, comm, self.bz)
else:
q = tests.clicomm(comm, self.bz, returnmain=True)
self.assertDictEqual(out, q)
示例13: test10Login
def test10Login(self):
"""
Failed login test, gives us a bit more coverage
"""
ret = tests.clicomm("bugzilla --bugzilla %s "
"--user [email protected] "
"--password foobar login" % self.url, None,
expectfail=True)
self.assertTrue("Login failed: " in ret)
示例14: test4NewBugAllFields
def test4NewBugAllFields(self):
"""
Create a bug using all 'new' fields, check some values, close it
"""
bz = self.bzclass(url=self.url, cookiefile=cf)
summary = ("python-bugzilla test manyfields bug %s" %
datetime.datetime.today())
url = "http://example.com"
osval = "Windows"
cc = "[email protected]"
blocked = "461686,461687"
dependson = "427301"
comment = "Test bug from python-bugzilla test suite"
newout = tests.clicomm("bugzilla new "
"--product Fedora --component python-bugzilla --version rawhide "
"--summary \"%s\" "
"--comment \"%s\" "
"--url %s --severity Urgent --priority Low --os %s "
"--arch ppc --cc %s --blocked %s --dependson %s "
"--outputformat \"%%{bug_id}\"" %
(summary, comment, url, osval, cc, blocked, dependson), bz)
self.assertTrue(len(newout.splitlines()) == 3)
bugid = int(newout.splitlines()[2])
bug = bz.getbug(bugid)
print "\nCreated bugid: %s" % bugid
self.assertEquals(bug.summary, summary)
self.assertEquals(bug.bug_file_loc, url)
self.assertEquals(bug.op_sys, osval)
self.assertEquals(bug.blocks, _split_int(blocked))
self.assertEquals(bug.depends_on, _split_int(dependson))
self.assertTrue(all([e in bug.cc for e in cc.split(",")]))
self.assertEquals(bug.longdescs[0]["text"], comment)
# Close the bug
tests.clicomm("bugzilla modify --close WONTFIX %s" % bugid,
bz)
bug.refresh()
self.assertEquals(bug.status, "CLOSED")
self.assertEquals(bug.resolution, "WONTFIX")
示例15: test9Whiteboards
def test9Whiteboards(self):
bz = self.bzclass(url=self.url, cookiefile=cf, tokenfile=tf)
bug_id = "663674"
cmd = "bugzilla modify %s " % bug_id
bug = bz.getbug(bug_id)
# Set all whiteboards
initval = str(random.randint(1, 1024))
tests.clicomm(cmd +
"--whiteboard =%sstatus "
"--devel_whiteboard =%sdevel "
"--internal_whiteboard '=%sinternal, security, foo security1' "
"--qa_whiteboard =%sqa " %
(initval, initval, initval, initval), bz)
bug.refresh()
self.assertEquals(bug.whiteboard, initval + "status")
self.assertEquals(bug.qa_whiteboard, initval + "qa")
self.assertEquals(bug.devel_whiteboard, initval + "devel")
self.assertEquals(bug.internal_whiteboard,
initval + "internal, security, foo security1")
# Modify whiteboards
tests.clicomm(cmd +
"--whiteboard =foobar "
"--qa_whiteboard _app ", bz)
bug.prependwhiteboard("pre-", "devel")
bug.refresh()
self.assertEquals(bug.qa_whiteboard, initval + "qa" + " _app")
self.assertEquals(bug.devel_whiteboard, "pre- " + initval + "devel")
self.assertEquals(bug.status_whiteboard, "foobar")
# Verify that tag manipulation is smart about separator
tests.clicomm(cmd +
"--qa_whiteboard -_app "
"--internal_whiteboard -security", bz)
bug.refresh()
self.assertEquals(bug.qa_whiteboard, initval + "qa")
self.assertEquals(bug.internal_whiteboard,
initval + "internal, foo security1")
bug.addtag("teststuff", "internal")
bug.refresh()
self.assertEquals(bug.internal_whiteboard,
initval + "internal, foo security1, teststuff")
# Clear whiteboards
bug.setwhiteboard("", "status")
bug.setwhiteboard("", "qa")
bug.setwhiteboard("", "devel")
bug.setwhiteboard("", "internal")
bug.refresh()
self.assertEquals(bug.whiteboard, "")
self.assertEquals(bug.qa_whiteboard, "")
self.assertEquals(bug.devel_whiteboard, "")
self.assertEquals(bug.internal_whiteboard, "")