def setUp(self):
        from letsencrypt.acme.messages import Error
        self.msg = Error(
            error='badCSR', message='RSA keys must be at least 2048 bits long',
            more_info='https://ca.example.com/documentation/csr-requirements')

        self.jmsg = {
            'type': 'error',
            'error': 'badCSR',
            'message':'RSA keys must be at least 2048 bits long',
            'moreInfo': 'https://ca.example.com/documentation/csr-requirements',
        }
class ErrorTest(unittest.TestCase):

    def setUp(self):
        from letsencrypt.acme.messages import Error
        self.msg = Error(
            error='badCSR', message='RSA keys must be at least 2048 bits long',
            more_info='https://ca.example.com/documentation/csr-requirements')

        self.jmsg = {
            'type': 'error',
            'error': 'badCSR',
            'message':'RSA keys must be at least 2048 bits long',
            'moreInfo': 'https://ca.example.com/documentation/csr-requirements',
        }

    def test_to_json(self):
        self.assertEqual(self.msg.to_json(), self.jmsg)

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

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

        from letsencrypt.acme.messages import Error
        msg = Error.from_json(self.jmsg)

        self.assertTrue(msg.message is None)
        self.assertTrue(msg.more_info is None)
        self.assertEqual(self.jmsg, msg.to_json())
class ErrorTest(unittest.TestCase):

    def setUp(self):
        from letsencrypt.acme.messages import Error
        self.msg = Error(
            error='badCSR', message='RSA keys must be at least 2048 bits long',
            more_info='https://ca.example.com/documentation/csr-requirements')

        self.jmsg = {
            'type': 'error',
            'error': 'badCSR',
            'message':'RSA keys must be at least 2048 bits long',
            'moreInfo': 'https://ca.example.com/documentation/csr-requirements',
        }

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

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

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

        from letsencrypt.acme.messages import Error
        msg = Error.from_json(self.jmsg)

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

        from letsencrypt.acme.messages import Error
        msg = Error.from_json(self.jmsg)

        self.assertTrue(msg.message is None)
        self.assertTrue(msg.more_info is None)
        self.assertEqual(self.jmsg, msg.to_json())
    def test_json_without_optionals(self):
        del self.jmsg['message']
        del self.jmsg['moreInfo']

        from letsencrypt.acme.messages import Error
        msg = Error.from_json(self.jmsg)

        self.assertTrue(msg.message is None)
        self.assertTrue(msg.more_info is None)
        self.assertEqual(self.jmsg, msg.to_partial_json())
    def setUp(self):
        from letsencrypt.acme.messages import Error
        self.msg = Error(
            error='badCSR', message='RSA keys must be at least 2048 bits long',
            more_info='https://ca.example.com/documentation/csr-requirements')

        self.jmsg = {
            'type': 'error',
            'error': 'badCSR',
            'message':'RSA keys must be at least 2048 bits long',
            'moreInfo': 'https://ca.example.com/documentation/csr-requirements',
        }
 def test_from_json(self):
     from letsencrypt.acme.messages import Error
     self.assertEqual(Error.from_json(self.jmsg), self.msg)
 def test_from_json(self):
     from letsencrypt.acme.messages import Error
     self.assertEqual(Error.from_json(self.jmsg), self.msg)