From ce8bed300627b6db2cc8ea4ad363e1b6b5dcd63e Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Thu, 22 Jan 2015 15:15:32 +0000 Subject: [PATCH] Add tests for pluggable hooks. Signed-off-by: brian m. carlson --- test/testfilemanip.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) 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()