コード例 #1
0
ファイル: misc.py プロジェクト: royxu1972/bugzilla-crawler
    def test_readconfig(self):
        bzapi = tests.make_bz("4.4.0", rhbz=True)
        bzapi.url = "foo.example.com"
        temp = tempfile.NamedTemporaryFile(mode="w")

        content = """
[example.com]
foo=1
user=test1
password=test2"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        self.assertEquals(bzapi.user, "test1")
        self.assertEquals(bzapi.password, "test2")

        content = """
[foo.example.com]
user=test3
password=test4"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        self.assertEquals(bzapi.user, "test3")
        self.assertEquals(bzapi.password, "test4")

        bzapi.url = "bugzilla.redhat.com"
        bzapi.user = None
        bzapi.password = None
        bzapi.readconfig(temp.name)
        self.assertEquals(bzapi.user, None)
        self.assertEquals(bzapi.password, None)
コード例 #2
0
ファイル: misc.py プロジェクト: djmitche/python-bugzilla
    def test_readconfig(self):
        bzapi = tests.make_bz("4.4.0", rhbz=True)
        bzapi.url = "foo.example.com"
        temp = tempfile.NamedTemporaryFile(mode="w")

        content = """
[example.com]
foo=1
user=test1
password=test2"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        self.assertEquals(bzapi.user, "test1")
        self.assertEquals(bzapi.password, "test2")

        content = """
[foo.example.com]
user=test3
password=test4"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        self.assertEquals(bzapi.user, "test3")
        self.assertEquals(bzapi.password, "test4")

        bzapi.url = "bugzilla.redhat.com"
        bzapi.user = None
        bzapi.password = None
        bzapi.readconfig(temp.name)
        self.assertEquals(bzapi.user, None)
        self.assertEquals(bzapi.password, None)
コード例 #3
0
    def testPostTranslation(self):
        def _testPostCompare(bz, indict, outexpect):
            outdict = indict.copy()
            bz.post_translation({}, outdict)
            self.assertTrue(outdict == outexpect)

            # Make sure multiple calls don't change anything
            bz.post_translation({}, outdict)
            self.assertTrue(outdict == outexpect)

        bug3 = tests.make_bz("3.4.0")
        rhbz = tests.make_bz("4.4.0", rhbz=True)

        test1 = {
            "component": ["comp1"],
            "version": ["ver1", "ver2"],

            'flags': [{
                'is_active': 1,
                'name': 'qe_test_coverage',
                'setter': '*****@*****.**',
                'status': '?',
            }, {
                'is_active': 1,
                'name': 'rhel-6.4.0',
                'setter': '*****@*****.**',
                'status': '+',
            }],

            'alias': ["FOO", "BAR"],
            'blocks': [782183, 840699, 923128],
            'keywords': ['Security'],
            'groups': ['redhat'],
        }

        out_simple = test1.copy()
        out_simple["components"] = out_simple["component"]
        out_simple["component"] = out_simple["components"][0]
        out_simple["versions"] = out_simple["version"]
        out_simple["version"] = out_simple["versions"][0]

        _testPostCompare(bug3, test1, test1)
        _testPostCompare(rhbz, test1, out_simple)
コード例 #4
0
    def testPostTranslation(self):
        def _testPostCompare(bz, indict, outexpect):
            outdict = indict.copy()
            bz.post_translation({}, outdict)
            assert outdict == outexpect

            # Make sure multiple calls don't change anything
            bz.post_translation({}, outdict)
            assert outdict == outexpect

        bug3 = tests.make_bz("3.4.0")
        rhbz = tests.make_bz("4.4.0", rhbz=True)

        test1 = {
            "component": ["comp1"],
            "version": ["ver1", "ver2"],

            'flags': [{
                'is_active': 1,
                'name': 'qe_test_coverage',
                'setter': '*****@*****.**',
                'status': '?',
            }, {
                'is_active': 1,
                'name': 'rhel-6.4.0',
                'setter': '*****@*****.**',
                'status': '+',
            }],

            'alias': ["FOO", "BAR"],
            'blocks': [782183, 840699, 923128],
            'keywords': ['Security'],
            'groups': ['redhat'],
        }

        out_simple = test1.copy()
        out_simple["components"] = out_simple["component"]
        out_simple["component"] = out_simple["components"][0]
        out_simple["versions"] = out_simple["version"]
        out_simple["version"] = out_simple["versions"][0]

        _testPostCompare(bug3, test1, test1)
        _testPostCompare(rhbz, test1, out_simple)
コード例 #5
0
ファイル: misc.py プロジェクト: xhe123/python-bugzilla
    def testCookies(self):
        cookiesbad = os.path.join(os.getcwd(), "tests/data/cookies-bad.txt")
        cookieslwp = os.path.join(os.getcwd(), "tests/data/cookies-lwp.txt")
        cookiesmoz = os.path.join(os.getcwd(), "tests/data/cookies-moz.txt")

        # We used to convert LWP cookies, but it shouldn't matter anymore,
        # so verify they fail at least
        try:
            tests.make_bz("3.0.0", cookiefile=cookieslwp)
            raise AssertionError("Expected BugzillaError from parsing %s" %
                                 os.path.basename(cookieslwp))
        except bugzilla.BugzillaError:
            # Expected result
            pass

        # Make sure bad cookies raise an error
        try:
            tests.make_bz("3.0.0", cookiefile=cookiesbad)
            raise AssertionError("Expected BugzillaError from parsing %s" %
                                 os.path.basename(cookiesbad))
        except bugzilla.BugzillaError:
            # Expected result
            pass

        # Mozilla should 'just work'
        tests.make_bz("3.0.0", cookiefile=cookiesmoz)
コード例 #6
0
ファイル: misc.py プロジェクト: crobinso/python-bugzilla
    def testCookies(self):
        cookiesbad = os.path.join(os.getcwd(), "tests/data/cookies-bad.txt")
        cookieslwp = os.path.join(os.getcwd(), "tests/data/cookies-lwp.txt")
        cookiesmoz = os.path.join(os.getcwd(), "tests/data/cookies-moz.txt")

        # We used to convert LWP cookies, but it shouldn't matter anymore,
        # so verify they fail at least
        try:
            tests.make_bz("3.0.0", cookiefile=cookieslwp)
            raise AssertionError("Expected BugzillaError from parsing %s" %
                                 os.path.basename(cookieslwp))
        except bugzilla.BugzillaError:
            # Expected result
            pass

        # Make sure bad cookies raise an error
        try:
            tests.make_bz("3.0.0", cookiefile=cookiesbad)
            raise AssertionError("Expected BugzillaError from parsing %s" %
                                 os.path.basename(cookiesbad))
        except bugzilla.BugzillaError:
            # Expected result
            pass

        # Mozilla should 'just work'
        tests.make_bz("3.0.0", cookiefile=cookiesmoz)
コード例 #7
0
    def test_readconfig(self):
        # Testing for bugzillarc handling
        bzapi = tests.make_bz("4.4.0", rhbz=True)
        bzapi.url = "example.com"
        temp = tempfile.NamedTemporaryFile(mode="w")

        content = """
[example.com]
foo=1
user=test1
password=test2"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        assert bzapi.user == "test1"
        assert bzapi.password == "test2"
        assert bzapi.api_key is None

        bzapi.url = "foo.example.com"
        bzapi.user = None
        bzapi.readconfig(temp.name)
        assert bzapi.user is None

        content = """
[foo.example.com]
user=test3
password=test4
api_key=123abc
"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        assert bzapi.user == "test3"
        assert bzapi.password == "test4"
        assert bzapi.api_key == "123abc"

        bzapi.url = "bugzilla.redhat.com"
        bzapi.user = None
        bzapi.password = None
        bzapi.api_key = None
        bzapi.readconfig(temp.name)
        assert bzapi.user is None
        assert bzapi.password is None
        assert bzapi.api_key is None
コード例 #8
0
    def test_readconfig(self):
        # Testing for bugzillarc handling
        bzapi = tests.make_bz("4.4.0", rhbz=True)
        bzapi.url = "example.com"
        temp = tempfile.NamedTemporaryFile(mode="w")

        content = """
[example.com]
foo=1
user=test1
password=test2"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        assert bzapi.user == "test1"
        assert bzapi.password == "test2"
        assert bzapi.api_key is None

        bzapi.url = "foo.example.com"
        bzapi.user = None
        bzapi.readconfig(temp.name)
        assert bzapi.user is None

        content = """
[foo.example.com]
user=test3
password=test4
api_key=123abc
"""
        temp.write(content)
        temp.flush()
        bzapi.readconfig(temp.name)
        assert bzapi.user == "test3"
        assert bzapi.password == "test4"
        assert bzapi.api_key == "123abc"

        bzapi.url = "bugzilla.redhat.com"
        bzapi.user = None
        bzapi.password = None
        bzapi.api_key = None
        bzapi.readconfig(temp.name)
        assert bzapi.user is None
        assert bzapi.password is None
        assert bzapi.api_key is None
コード例 #9
0
    def testCookies(self):
        cookiesbad = os.path.join(os.getcwd(), "tests/data/cookies-bad.txt")
        cookieslwp = os.path.join(os.getcwd(), "tests/data/cookies-lwp.txt")
        cookiesmoz = os.path.join(os.getcwd(), "tests/data/cookies-moz.txt")

        # We used to convert LWP cookies, but it shouldn't matter anymore,
        # so verify they fail at least
        with pytest.raises(bugzilla.BugzillaError):
            tests.make_bz("3.0.0", cookiefile=cookieslwp)

        with pytest.raises(bugzilla.BugzillaError):
            tests.make_bz("3.0.0", cookiefile=cookiesbad)

        # Mozilla should 'just work'
        tests.make_bz("3.0.0", cookiefile=cookiesmoz)
コード例 #10
0
    def testCookies(self):
        cookiesbad = os.path.join(os.getcwd(), "tests/data/cookies-bad.txt")
        cookieslwp = os.path.join(os.getcwd(), "tests/data/cookies-lwp.txt")
        cookiesmoz = os.path.join(os.getcwd(), "tests/data/cookies-moz.txt")

        # We used to convert LWP cookies, but it shouldn't matter anymore,
        # so verify they fail at least
        with pytest.raises(bugzilla.BugzillaError):
            tests.make_bz("3.0.0", cookiefile=cookieslwp)

        with pytest.raises(bugzilla.BugzillaError):
            tests.make_bz("3.0.0", cookiefile=cookiesbad)

        # Mozilla should 'just work'
        tests.make_bz("3.0.0", cookiefile=cookiesmoz)
コード例 #11
0
ファイル: modify.py プロジェクト: tglgame/python-bugzilla
# Copyright Red Hat, Inc. 2013
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
#

'''
Unit tests for building update dictionaries with 'bugzilla modify'
'''

import unittest

import tests


rhbz = tests.make_bz("4.4.0", rhbz=True)


class ModifyTest(unittest.TestCase):
    maxDiff = None
    bz = rhbz

    def assertDictEqual(self, *args, **kwargs):
        # EPEL5 back compat
        if hasattr(unittest.TestCase, "assertDictEqual"):
            return unittest.TestCase.assertDictEqual(self, *args, **kwargs)
        return self.assertEqual(*args, **kwargs)

    def clicomm(self, argstr, out, wbout=None, tags_add=None, tags_rm=None):
        comm = "bugzilla modify --test-return-result 123456 224466 " + argstr
        # pylint: disable=unpacking-non-sequence
コード例 #12
0
# Copyright Red Hat, Inc. 2013
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
#

"""
Unit tests for building createbug dictionaries with bin/bugzilla
"""

import unittest

import tests


bz4 = tests.make_bz("4.0.0")


class CreatebugTest(unittest.TestCase):
    bz = bz4

    def clicomm(self, argstr, out):
        comm = "bugzilla new --__test-return-result " + argstr
        q = tests.clicomm(comm, self.bz, returnmain=True)
        assert out == q

    def testBasic(self):
        self.clicomm(
            "--product foo --component bar --summary baz --version 12",
            {'component': 'bar', 'product': 'foo',
             'summary': 'baz', 'version': '12'}
コード例 #13
0
ファイル: query.py プロジェクト: djmitche/python-bugzilla
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
#

'''
Unit tests for building query strings with bin/bugzilla
'''

import copy
import os
import unittest

import tests

bz34 = tests.make_bz("3.4.0")
bz4 = tests.make_bz("4.0.0")
rhbz4 = tests.make_bz("4.4.0", rhbz=True)


class BZ34Test(unittest.TestCase):
    """
    This is the base query class, but it's also functional on its
    own.
    """
    maxDiff = None

    def assertDictEqual(self, *args, **kwargs):
        # EPEL5 back compat
        if hasattr(unittest.TestCase, "assertDictEqual"):
            return unittest.TestCase.assertDictEqual(self, *args, **kwargs)
コード例 #14
0
ファイル: misc.py プロジェクト: xhe123/python-bugzilla
 def testUserAgent(self):
     b3 = tests.make_bz("3.0.0")
     self.assertTrue("python-bugzilla" in b3.user_agent)
コード例 #15
0
#
# Copyright Red Hat, Inc. 2013
#
# This work is licensed under the terms of the GNU GPL, version 2 or later.
# See the COPYING file in the top-level directory.
#
'''
Unit tests for building createbug dictionaries with bin/bugzilla
'''

import unittest

import tests

bz4 = tests.make_bz("4.0.0")


class CreatebugTest(unittest.TestCase):
    maxDiff = None
    bz = bz4

    def assertDictEqual(self, *args, **kwargs):
        # EPEL5 back compat
        if hasattr(unittest.TestCase, "assertDictEqual"):
            return unittest.TestCase.assertDictEqual(self, *args, **kwargs)
        return self.assertEqual(*args, **kwargs)

    def clicomm(self, argstr, out):
        comm = "bugzilla new --test-return-result " + argstr

        if out is None:
コード例 #16
0
ファイル: test_query.py プロジェクト: yazug/python-bugzilla
# See the COPYING file in the top-level directory.
#

"""
Unit tests for building query strings with bin/bugzilla
"""

import copy
import os
import unittest

import pytest

import tests

bz34 = tests.make_bz("3.4.0")
bz4 = tests.make_bz("4.0.0")
rhbz4 = tests.make_bz("4.4.0", rhbz=True)


class BZ34Test(unittest.TestCase):
    """
    This is the base query class, but it's also functional on its
    own.
    """
    def clicomm(self, argstr, out):
        comm = "bugzilla query --__test-return-result " + argstr

        if not out:
            with pytest.raises(RuntimeError):
                tests.clicomm(comm, self.bz)
コード例 #17
0
 def testUserAgent(self):
     b3 = tests.make_bz("3.0.0")
     assert "python-bugzilla" in b3.user_agent