class RecoveryTokenResponseTest(unittest.TestCase):

    def setUp(self):
        from letsencrypt.acme.challenges import RecoveryTokenResponse
        self.msg = RecoveryTokenResponse(token='23029d88d9e123e')
        self.jmsg = {'type': 'recoveryToken', 'token': '23029d88d9e123e'}

    def test_to_partial_json(self):
        self.assertEqual(self.jmsg, self.msg.to_partial_json())

    def test_from_json(self):
        from letsencrypt.acme.challenges import RecoveryTokenResponse
        self.assertEqual(
            self.msg, RecoveryTokenResponse.from_json(self.jmsg))

    def test_from_json_hashable(self):
        from letsencrypt.acme.challenges import RecoveryTokenResponse
        hash(RecoveryTokenResponse.from_json(self.jmsg))

    def test_json_without_optionals(self):
        del self.jmsg['token']

        from letsencrypt.acme.challenges import RecoveryTokenResponse
        msg = RecoveryTokenResponse.from_json(self.jmsg)

        self.assertTrue(msg.token is None)
        self.assertEqual(self.jmsg, msg.to_partial_json())
class RecoveryTokenResponseTest(unittest.TestCase):
    def setUp(self):
        from letsencrypt.acme.challenges import RecoveryTokenResponse
        self.msg = RecoveryTokenResponse(token='23029d88d9e123e')
        self.jmsg = {'type': 'recoveryToken', 'token': '23029d88d9e123e'}

    def test_to_partial_json(self):
        self.assertEqual(self.jmsg, self.msg.to_partial_json())

    def test_from_json(self):
        from letsencrypt.acme.challenges import RecoveryTokenResponse
        self.assertEqual(self.msg, RecoveryTokenResponse.from_json(self.jmsg))

    def test_from_json_hashable(self):
        from letsencrypt.acme.challenges import RecoveryTokenResponse
        hash(RecoveryTokenResponse.from_json(self.jmsg))

    def test_json_without_optionals(self):
        del self.jmsg['token']

        from letsencrypt.acme.challenges import RecoveryTokenResponse
        msg = RecoveryTokenResponse.from_json(self.jmsg)

        self.assertTrue(msg.token is None)
        self.assertEqual(self.jmsg, msg.to_partial_json())
    def test_json_without_optionals(self):
        del self.jmsg['token']

        from letsencrypt.acme.challenges import RecoveryTokenResponse
        msg = RecoveryTokenResponse.from_json(self.jmsg)

        self.assertTrue(msg.token is None)
        self.assertEqual(self.jmsg, msg.to_partial_json())
    def test_json_without_optionals(self):
        del self.jmsg['token']

        from letsencrypt.acme.challenges import RecoveryTokenResponse
        msg = RecoveryTokenResponse.from_json(self.jmsg)

        self.assertTrue(msg.token is None)
        self.assertEqual(self.jmsg, msg.to_json())
 def test_from_json_hashable(self):
     from letsencrypt.acme.challenges import RecoveryTokenResponse
     hash(RecoveryTokenResponse.from_json(self.jmsg))
 def test_from_json(self):
     from letsencrypt.acme.challenges import RecoveryTokenResponse
     self.assertEqual(
         self.msg, RecoveryTokenResponse.from_json(self.jmsg))
 def setUp(self):
     from letsencrypt.acme.challenges import RecoveryTokenResponse
     self.msg = RecoveryTokenResponse(token='23029d88d9e123e')
     self.jmsg = {'type': 'recoveryToken', 'token': '23029d88d9e123e'}
 def test_from_json(self):
     from letsencrypt.acme.challenges import RecoveryTokenResponse
     self.assertEqual(self.msg, RecoveryTokenResponse.from_json(self.jmsg))
 def setUp(self):
     from letsencrypt.acme.challenges import RecoveryTokenResponse
     self.msg = RecoveryTokenResponse(token='23029d88d9e123e')
     self.jmsg = {'type': 'recoveryToken', 'token': '23029d88d9e123e'}
 def test_from_json_hashable(self):
     from letsencrypt.acme.challenges import RecoveryTokenResponse
     hash(RecoveryTokenResponse.from_json(self.jmsg))