示例#1
0
    def testBasic(self):
        data = {
            "bug_id": 123456,
            "status": "NEW",
            "assigned_to": "*****@*****.**",
            "component": "foo",
            "product": "bar",
            "short_desc": "some short desc",
            "cf_fixed_in": "nope",
            "fixed_in": "1.2.3.4",
            "devel_whiteboard": "some status value",
        }

        bug = _Bug(bugzilla=self.bz, dict=data)

        def _assert_bug():
            self.assertEqual(hasattr(bug, "component"), True)
            self.assertEqual(getattr(bug, "components"), ["foo"])
            self.assertEqual(getattr(bug, "product"), "bar")
            self.assertEqual(hasattr(bug, "short_desc"), True)
            self.assertEqual(getattr(bug, "summary"), "some short desc")
            self.assertEqual(bool(getattr(bug, "cf_fixed_in")), True)
            self.assertEqual(getattr(bug, "fixed_in"), "1.2.3.4")
            self.assertEqual(bool(getattr(bug, "cf_devel_whiteboard")), True)
            self.assertEqual(getattr(bug, "devel_whiteboard"),
                "some status value")

        _assert_bug()

        self.assertEqual(str(bug),
            "#123456 NEW        - [email protected] - some short desc")
        self.assertTrue(repr(bug).startswith("<Bug #123456"))

        # This triggers some code in __getattr__
        dir(bug)

        # Test special pickle support
        if hasattr(sys.version_info, "major") and sys.version_info.major >= 3:
            from io import BytesIO
            fd = BytesIO()
        else:
            fd = StringIO()

        pickle.dump(bug, fd)
        fd.seek(0)
        bug = pickle.load(fd)
        self.assertEqual(getattr(bug, "bugzilla"), None)
        bug.bugzilla = self.bz
        _assert_bug()
示例#2
0
 def testBugNoID(self):
     try:
         _Bug(bugzilla=self.bz, dict={"component": "foo"})
         raise AssertionError("Expected lack of ID failure.")
     except TypeError:
         pass