diff --git a/test/testfilemanip.py b/test/testfilemanip.py index d9adc2a..9551169 100755 --- a/test/testfilemanip.py +++ b/test/testfilemanip.py @@ -253,6 +253,10 @@ class ExampleFile(newfol.filemanip.FileFormat): return [Record(['a', 'b'])] +class ExampleHook(newfol.filemanip.Hook): + pass + + class PluggableBackendsTest(unittest.TestCase): def test_adding_backend(self): FileStorage.register_backend('example', ExampleFile) @@ -269,5 +273,18 @@ class PluggableBackendsTest(unittest.TestCase): with self.assertRaises(KeyError): FileStorage.BACKENDS['example'] + +class PluggableHooksTest(unittest.TestCase): + def test_adding_hook(self): + FileStorage.register_hook('example', ExampleHook) + self.assertEqual(FileStorage.HOOKS['example'], ExampleHook) + + def test_removing_hook(self): + FileStorage.register_hook('example', ExampleFile) + self.assertEqual(FileStorage.HOOKS['example'], ExampleFile) + FileStorage.unregister_hook('example') + with self.assertRaises(KeyError): + FileStorage.HOOKS['example'] + if __name__ == '__main__': unittest.main()