[tor-commits] [bridgedb/develop] Add additional unittests for crypto.LessCrypticGPGMEError.

isis at torproject.org isis at torproject.org
Wed May 14 03:42:28 UTC 2014


commit 55af823890f141edb07cebdbab47a20fb8e45bf3
Author: Isis Lovecruft <isis at torproject.org>
Date:   Wed Apr 23 04:09:46 2014 +0000

    Add additional unittests for crypto.LessCrypticGPGMEError.
---
 lib/bridgedb/test/test_crypto.py |   30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/lib/bridgedb/test/test_crypto.py b/lib/bridgedb/test/test_crypto.py
index f828ef0..935a784 100644
--- a/lib/bridgedb/test/test_crypto.py
+++ b/lib/bridgedb/test/test_crypto.py
@@ -17,6 +17,7 @@ from __future__ import unicode_literals
 import gpgme
 import io
 import logging
+import math
 import os
 import shutil
 
@@ -105,6 +106,35 @@ class LessCrypticGPGMEErrorTests(unittest.TestCase):
 
         self.assertTrue('Invalid argument' in lessCryptic.message)
 
+    def test_noGpgmeErrorArgs(self):
+        """A gpgme.GpgmeError() without error code args should result in a
+        'Could not get error code from gpgme.GpgmeError!' message.
+        """
+        error = gpgme.GpgmeError()
+        lessCryptic = crypto.LessCrypticGPGMEError(error)
+        self.assertEqual(lessCryptic.message,
+                         'Could not get error code from gpgme.GpgmeError!')
+
+    def test_unknownErrorSource(self):
+        """A gpgme.GpgmeError() without a recognisable error source should say
+        that the error source is 'UNKNOWN'.
+        """
+        msg = "These numbers make more sense than libgpgme's error codes."
+        error = gpgme.GpgmeError(math.pi, math.e, msg)
+        lessCryptic = crypto.LessCrypticGPGMEError(error)
+        self.assertSubstring('UNKNOWN', lessCryptic.message)
+        self.assertSubstring(msg, lessCryptic.message)
+
+    def test_unknownErrorCode(self):
+        """A gpgme.GpgmeError() without a recognisable error code should say
+        that the error code is 'UNKNOWN'.
+        """
+        msg = "These numbers make more sense than libgpgme's error codes."
+        error = gpgme.GpgmeError(math.pi, math.e, msg)
+        lessCryptic = crypto.LessCrypticGPGMEError(error)
+        self.assertSubstring('UNKNOWN', lessCryptic.message)
+        self.assertSubstring(msg, lessCryptic.message)
+
 
 class SSLVerifyingContextFactoryTests(unittest.TestCase,
                                       txtagent.FakeReactorAndConnectMixin):





More information about the tor-commits mailing list