def test_assert_script_keeps_page_content_if_pages_already_exist(self): create_careers_pages.run() careers = Page.objects.get(slug='careers') careers.title = 'test title' save_page(careers) create_careers_pages.run() careers_after_rerun = Page.objects.get(slug='careers') self.assertEqual(careers_after_rerun.title, 'test title')
def validate_page(self, page, fix=False): diffsets = [] for block in page.content: if not isinstance(block.block, RawHTMLBlock): continue try: corrected = self.correct_html(block.value) except Exception: print('failed page validation:', page.full_url) raise if corrected != block.value: diffset = ndiff(block.value.split('\n'), corrected.split('\n')) diffsets.append( d for d in diffset if d.startswith('- ') or d.startswith('+ ') ) block.value = corrected if diffsets: print('\ndetected invalid page:', page.full_url) for diffset in diffsets: for diff in diffset: print(diff) if fix: revision = save_page(page) if page.live: revision.publish()
def validate_page(self, page, fix=False): diffsets = [] for block in page.content: if not isinstance(block.block, RawHTMLBlock): continue try: corrected = self.correct_html(block.value) except Exception: print('failed page validation:', page.full_url) raise if corrected != block.value: diffset = ndiff(block.value.split('\n'), corrected.split('\n')) diffsets.append(d for d in diffset if d.startswith('- ') or d.startswith('+ ')) block.value = corrected if diffsets: print('\ndetected invalid page:', page.full_url) for diffset in diffsets: for diff in diffset: print(diff) if fix: revision = save_page(page) if page.live: revision.publish()