Improve Account.repr() (#4325)

* Include more detail in Account's repr.

In particular, regr and meta.

* Fix test.

* Review feedback.

* Lint

* Test prefix only.
This commit is contained in:
Jacob Hoffman-Andrews 2017-04-18 17:09:22 -07:00 committed by Brad Warren
parent b0600483fd
commit d54cb3c59d
2 changed files with 5 additions and 5 deletions

View file

@ -74,7 +74,8 @@ class Account(object): # pylint: disable=too-few-public-methods
self.meta.creation_dt), self.meta.creation_host, self.id[:4])
def __repr__(self):
return "<{0}({1})>".format(self.__class__.__name__, self.id)
return "<{0}({1}, {2}, {3})>".format(
self.__class__.__name__, self.regr, self.id, self.meta)
def __eq__(self, other):
return (isinstance(other, self.__class__) and

View file

@ -33,6 +33,7 @@ class AccountTest(unittest.TestCase):
creation_dt=datetime.datetime(
2015, 7, 4, 14, 4, 10, tzinfo=pytz.UTC))
self.acc = Account(self.regr, KEY, self.meta)
self.regr.__repr__ = mock.MagicMock(return_value="i_am_a_regr")
with mock.patch("certbot.account.socket") as mock_socket:
mock_socket.getfqdn.return_value = "test.certbot.org"
@ -54,10 +55,8 @@ class AccountTest(unittest.TestCase):
self.acc.slug, "test.certbot.org@2015-07-04T14:04:10Z (bca5)")
def test_repr(self):
self.assertEqual(
repr(self.acc),
"<Account(bca5889f66457d5b62fbba7b25f9ab6f)>")
self.assertTrue(repr(self.acc).startswith(
"<Account(i_am_a_regr, bca5889f66457d5b62fbba7b25f9ab6f, Meta("))
class ReportNewAccountTest(unittest.TestCase):
"""Tests for certbot.account.report_new_account."""