def make_page_fixture(page_id=None, title=None, body=None, space_key='TEST'): p = Page() p.id = page_id p.space_key = space_key p.title = title p.body = body return p
def test_watermark_page_mutator_add(self): watermark = 'test' content = 'page content' page = Page() page.body = content WatermarkPageMutator(watermark).apply_forward(page) self.assertNotEqual(content, page.body)
def test_watermark_page_mutator_remove(self): watermark = 'test' clean_content = 'page content' page = Page() page.body = WatermarkPageMutator.template_prefix + \ WatermarkPageMutator.template.format(watermark=watermark) + \ WatermarkPageMutator.template_suffix + clean_content WatermarkPageMutator(watermark).apply_backward(page) self.assertEqual(clean_content, page.body)
def test_eq(self): fixture_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'fixtures', 'page_body.html') body_fixture = codecs.open(fixture_file, 'r', encoding='utf-8').read() first_ancestor = Ancestor() first_ancestor.id = 12344 first = Page() first.id = 12345 first.type = 'page' first.body = body_fixture first.ancestors.append(first_ancestor) second = copy.deepcopy(first) self.assertTrue(first == second)
def test_anchor_page_mutator_mutate(self): original_content = u''' <p>Default response</p>\n<p>Type: <a class="reference internal" href="#SnowTeq1.0.0-d-c40da07e339eaa512fd6189 f="#SnowTeq1.0.0-d-c40da07e339eaa512fd6189758a42db6"><span>ClubsSerializer</span></a></p>\n<p><strong>Example <a class="reference internal" href="#SnowTeq1.0.0-d-c40da07e339eaa512fd6189758a42db6"><span>ClubsSerializer</ ''' correct_content = u''' <p>Default response</p>\n<p>Type: <a class="reference internal" href="#TestPage#2-d-c40da07e339eaa512fd6189 f="#TestPage#2-d-c40da07e339eaa512fd6189758a42db6"><span>ClubsSerializer</span></a></p>\n<p><strong>Example <a class="reference internal" href="#TestPage#2-d-c40da07e339eaa512fd6189758a42db6"><span>ClubsSerializer</ ''' page_new_title = u'SnowTeq 1.0.0' page_old_title = u'Test Page #2' page = Page() page.body = original_content # means hold-title = True page.title = page_old_title AnchorPageMutator(page_new_title).apply_forward(page) self.assertEqual(correct_content, page.body)
def __init__(self): self.config = ConfigLoader.from_dict({ 'version': 2, 'base_dir': 'fixtures', 'pages': [{ 'id': 1, 'source': 'page', 'attachments': { 'images': ['test_image.png'], 'downloads': ['test_download.txt'], } }, { 'source': 'page', 'title': 'cfgTitle' }, { 'id': 1, 'source': 'titeless_page', 'watermark': 'just mark it!', 'link': 'http://localhost:8080/index.htm' }] }) page = Page() page.id = 1 page.title = u'pageTitle' page.unused_title = u'Useless' page.body = u''' Body <a href="{}">Title</a> <a href="{}">Unused</a> '''.format(page.title, page.unused_title) self.tests_root = os.path.dirname(os.path.abspath(__file__)) self.data_provider = SphinxFJsonDataProvider( root_dir=self.tests_root, base_dir=self.config.base_dir) self.page_manager = FakePagePublisher([page]) self.attachment_manager = FakeAttachmentPublisher()