def testBasic(): 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=rhbz, dict=data) def _assert_bug(): assert hasattr(bug, "component") is True assert getattr(bug, "components") == ["foo"] assert getattr(bug, "product") == "bar" assert hasattr(bug, "short_desc") is True assert getattr(bug, "summary") == "some short desc" assert bool(getattr(bug, "cf_fixed_in")) is True assert getattr(bug, "fixed_in") == "1.2.3.4" assert bool(getattr(bug, "cf_devel_whiteboard")) is True assert getattr(bug, "devel_whiteboard") == "some status value" _assert_bug() assert str(bug) == "#123456 NEW - [email protected] - some short desc" assert repr(bug).startswith("<Bug #123456") # This triggers some code in __getattr__ dir(bug) # Test special pickle support if sys.version_info[0] >= 3: import io fd = io.BytesIO() else: import StringIO # pylint: disable=import-error fd = StringIO.StringIO() pickle.dump(bug, fd) fd.seek(0) bug = pickle.load(fd) assert getattr(bug, "bugzilla") is None assert str(bug) assert repr(bug) bug.bugzilla = rhbz _assert_bug()
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()
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(): assert hasattr(bug, "component") is True assert getattr(bug, "components") == ["foo"] assert getattr(bug, "product") == "bar" assert hasattr(bug, "short_desc") is True assert getattr(bug, "summary") == "some short desc" assert bool(getattr(bug, "cf_fixed_in")) is True assert getattr(bug, "fixed_in") == "1.2.3.4" assert bool(getattr(bug, "cf_devel_whiteboard")) is True assert getattr(bug, "devel_whiteboard") == "some status value" _assert_bug() assert str(bug) == "#123456 NEW - [email protected] - some short desc" assert repr(bug).startswith("<Bug #123456") # This triggers some code in __getattr__ dir(bug) # Test special pickle support if sys.version_info[0] >= 3: from io import BytesIO fd = BytesIO() else: fd = StringIO() pickle.dump(bug, fd) fd.seek(0) bug = pickle.load(fd) assert getattr(bug, "bugzilla") is None bug.bugzilla = self.bz _assert_bug()