def test_watchdog(self): PublicatorRegistry.unregister('pdf') PublicatorRegistry.unregister('printable-pdf') PublicatorRegistry.unregister('epub') PublicatorRegistry.unregister('html') with open('path', 'w') as f: f.write('my_content;/path/to/markdown.md') @PublicatorRegistry.register('test', '', '') class TestPublicator(Publicator): def __init__(self, *__): pass PublicatorRegistry.get('test').publish = Mock() event = FileCreatedEvent('path') handler = TutorialIsPublished() handler.prepare_generation = Mock() handler.finish_generation = Mock() handler.on_created(event) self.assertTrue(PublicatorRegistry.get('test').publish.called) handler.finish_generation.assert_called_with('/path/to', 'path') handler.prepare_generation.assert_called_with('/path/to') os.remove('path')
def test_watchdog(self): PublicatorRegistery.unregister('pdf') PublicatorRegistery.unregister('epub') PublicatorRegistery.unregister('html') with open('path', 'w') as f: f.write('my_content;/path/to/markdown.md') @PublicatorRegistery.register('test', '', '') class TestPublicator(Publicator): def __init__(self, *__): pass PublicatorRegistery.get('test').publish = Mock() event = FileCreatedEvent('path') handler = TutorialIsPublished() handler.prepare_generation = Mock() handler.finish_generation = Mock() handler.on_created(event) self.assertTrue(PublicatorRegistery.get('test').publish.called) handler.finish_generation.assert_called_with('/path/to', 'path') handler.prepare_generation.assert_called_with('/path/to') os.remove('path')
def test_watchdog(self): PublicatorRegistery.unregister("pdf") PublicatorRegistery.unregister("epub") PublicatorRegistery.unregister("html") with open("path", "w") as f: f.write("my_content;/path/to/markdown.md") @PublicatorRegistery.register("test", "", "") class TestPublicator(Publicator): def __init__(self, *__): pass PublicatorRegistery.get("test").publish = Mock() event = FileCreatedEvent("path") handler = TutorialIsPublished() handler.prepare_generation = Mock() handler.finish_generation = Mock() handler.on_created(event) self.assertTrue(PublicatorRegistery.get("test").publish.called) handler.finish_generation.assert_called_with("/path/to", "path") handler.prepare_generation.assert_called_with("/path/to") os.remove("path")