import unittest
from unittest import mock

from .test_file import FileKeyringTests

from keyrings.cryptfile import cryptfile

def is_crypto_supported():
    try:
        __import__('argon2.low_level')
        __import__('Crypto.Cipher.AES')
    except ImportError:
        return False
    return True


@unittest.skipUnless(is_crypto_supported(),
                     "Need argon2_cffi and PyCryptodome package")
class CryptFileKeyringTestCase(FileKeyringTests, unittest.TestCase):

    def setUp(self):
        super(self.__class__, self).setUp()
        fake_getpass = mock.Mock(return_value='abcdef')
        self.patcher = mock.patch('getpass.getpass', fake_getpass)
        self.patcher.start()

    def tearDown(self):
        self.patcher.stop()

    def init_keyring(self):
        return cryptfile.CryptFileKeyring()

@@ -433,20 +433,17 @@
 ringTest
-Case
+s
 (FileKey
@@ -455,27 +455,8 @@
 ests
-, unittest.TestCase
 ):%0A%0A
@@ -494,22 +494,29 @@
 per(
-self.__class__
+CryptFileKeyringTests
 , se
@@ -773,40 +773,1131 @@
     
-return cryptfile.CryptFileKeyring()
+kr = cryptfile.CryptFileKeyring()%0A        mode = self.__class__.__name__%5B:3%5D%0A        if mode in kr._get_mode():%0A            kr.aesmode = mode%0A        return kr%0A%0A    def test_file(self):%0A        self.assertTrue(self.keyring._check_file() != True)%0A%0A%0A@unittest.skipUnless(is_crypto_supported(),%0A                     %22Need argon2_cffi and PyCryptodome package%22)%0Aclass CryptFileKeyringTestCase(CryptFileKeyringTests, unittest.TestCase):%0A    %22%22%22 test default AES mode (GCM) %22%22%22%0A%0A#@unittest.skipUnless(is_crypto_supported(),%0A#                     %22Need argon2_cffi and PyCryptodome package%22)%0A#class EAXCryptFileKeyringTestCase(CryptFileKeyringTests, unittest.TestCase):%0A#    %22%22%22 test EAX mode %22%22%22%0A%0A#@unittest.skipUnless(is_crypto_supported(),%0A#                     %22Need argon2_cffi and PyCryptodome package%22)%0A#class CCMCryptFileKeyringTestCase(CryptFileKeyringTests, unittest.TestCase):%0A#    %22%22%22 test CCM mode %22%22%22%0A%0A#@unittest.skipUnless(is_crypto_supported(),%0A#                     %22Need argon2_cffi and PyCryptodome package%22)%0A#class OCCBCryptFileKeyringTestCase(CryptFileKeyringTests, unittest.TestCase):%0A#    %22%22%22 test OCB mode %22%22%22
 %0A

prepare for testing all AES modes (disabled for now)