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")
def setUp(self): self.overridden_zds_app = overridden_zds_app self.mas = ProfileFactory().user overridden_zds_app['member']['bot_account'] = self.mas.username self.licence = LicenceFactory() self.user_author = ProfileFactory().user self.staff = StaffProfileFactory().user self.tuto = PublishableContentFactory(type='TUTORIAL') self.tuto.authors.add(self.user_author) UserGalleryFactory(gallery=self.tuto.gallery, user=self.user_author, mode='W') self.tuto.licence = self.licence self.tuto.save() self.tuto_draft = self.tuto.load_version() self.part1 = ContainerFactory(parent=self.tuto_draft, db_object=self.tuto) self.chapter1 = ContainerFactory(parent=self.part1, db_object=self.tuto) self.old_registry = { key: value for key, value in PublicatorRegistery.get_all_registered() }
def setUp(self): # don't build PDF to speed up the tests settings.ZDS_APP['content']['build_pdf_when_published'] = False settings.EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' self.mas = ProfileFactory().user settings.ZDS_APP['member']['bot_account'] = self.mas.username self.licence = LicenceFactory() self.user_author = ProfileFactory().user self.staff = StaffProfileFactory().user self.tuto = PublishableContentFactory(type='TUTORIAL') self.tuto.authors.add(self.user_author) UserGalleryFactory(gallery=self.tuto.gallery, user=self.user_author, mode='W') self.tuto.licence = self.licence self.tuto.save() self.tuto_draft = self.tuto.load_version() self.part1 = ContainerFactory(parent=self.tuto_draft, db_object=self.tuto) self.chapter1 = ContainerFactory(parent=self.part1, db_object=self.tuto) self.old_registry = { key: value for key, value in PublicatorRegistery.get_all_registered() }