def test_sha512salt_get(self):
        '''This test case ensures sha512 with salt passwords hasher can be instantiated using the factory.'''

        sha512_hasher = PasswordsHasherFactory().get_hasher(
            PasswordsHasherFactory.SHA512_SALT)

        self.assertIsInstance(sha512_hasher, Sha512SaltPasswordsHasher)
class PasswordsHasherFactoryTests(FantasticoUnitTestsCase):
    '''This class provides the tests suite which ensures passwords hasher factory correct behavior.'''

    _factory = None

    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()

    def test_sha512salt_get(self):
        '''This test case ensures sha512 with salt passwords hasher can be instantiated using the factory.'''

        sha512_hasher = PasswordsHasherFactory().get_hasher(PasswordsHasherFactory.SHA512_SALT)

        self.assertIsInstance(sha512_hasher, Sha512SaltPasswordsHasher)

    def test_unsupportedalg_get(self):
        '''This test case ensures a concrete exception is raised if the requested algorithm is not supported.'''

        with self.assertRaises(OAuth2TokenEncryptionError):
            self._factory.get_hasher("unknown algorithm")
class PasswordsHasherFactoryTests(FantasticoUnitTestsCase):
    '''This class provides the tests suite which ensures passwords hasher factory correct behavior.'''

    _factory = None

    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()

    def test_sha512salt_get(self):
        '''This test case ensures sha512 with salt passwords hasher can be instantiated using the factory.'''

        sha512_hasher = PasswordsHasherFactory().get_hasher(
            PasswordsHasherFactory.SHA512_SALT)

        self.assertIsInstance(sha512_hasher, Sha512SaltPasswordsHasher)

    def test_unsupportedalg_get(self):
        '''This test case ensures a concrete exception is raised if the requested algorithm is not supported.'''

        with self.assertRaises(OAuth2TokenEncryptionError):
            self._factory.get_hasher("unknown algorithm")
    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()
    def init(self):
        '''This method is invoked automatically in order to setup common dependencies for all test cases.'''

        self._factory = PasswordsHasherFactory()