Add tests for pluggable hooks.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
parent
20a5e43043
commit
ce8bed3006
1 changed files with 17 additions and 0 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Reference in a new issue