Ver código fonte

Add some testing to CryptoEngine.get()

oz123 10 anos atrás
pai
commit
dfc7f97139
1 arquivos alterados com 11 adições e 1 exclusões
  1. 11 1
      pwman/tests/crypto_tests.py

+ 11 - 1
pwman/tests/crypto_tests.py

@@ -1,7 +1,7 @@
 import pwman.util.config as config
 import os
 from pwman.util.crypto import (CryptoEngine, CryptoException,
-                               CryptoNoCallbackException)
+                               CryptoNoCallbackException, CryptoEngineOld)
 # set cls_timout to negative number (e.g. -1) to disable
 default_config = {'Global': {'umask': '0100', 'colors': 'yes',
                              'cls_timeout': '5'
@@ -30,3 +30,13 @@ class CryptoTest(unittest.TestCase):
     def test_prepare_data(self):
         obj = 'dummy_data'
         self.assertTrue(True)
+
+    def test_get(self):
+        old_engine = CryptoEngine.get()
+        self.assertIsInstance(old_engine, CryptoEngineOld)
+        CryptoEngine._instance = None
+        new_engine = CryptoEngine.get(dbver=0.5)
+        self.assertIsInstance(new_engine, CryptoEngine)
+        self.assertFalse(isinstance(new_engine, CryptoEngineOld))
+        CryptoEngine._instance = None
+        old_engine = CryptoEngine.get()