def test_merge_into_section_not_same_reference(self): target = Section('The title\n' 'Styleguide a.b') target.parse() source = Section('Title suffix\n' 'StyleguideExtendBefore a.c') source.parse() with self.assertRaises(InvalidMergeNotSameReferenceError): source.merge_into_section(target_section=target)
def test_merge_into_section_invalid_section_type(self): target = Section('The title\nStyleguide a.b') target.parse() source = Section('Title suffix\nStyleguide a.b') source.parse() with self.assertRaises(InvalidMergeSectionTypeError): source.merge_into_section(target_section=target)
def test_merge_into_section_before_no_title(self): target = Section('The title\nThe description\nStyleguide a.b') target.parse() source = Section('Extra description\nStyleguideExtendBefore a.b') source.parse() source.merge_into_section(target_section=target) self.assertEqual(target.title, 'The title') self.assertEqual(target.description, 'Extra description\n\nThe description')
def test_merge_into_section_before_example(self): target = Section('The title\n' 'Example:\n <em>example</em>\n' 'Styleguide a.b') target.parse() source = Section('Example:\n <em>example2</em>\n' 'StyleguideExtendBefore a.b') source.parse() source.merge_into_section(target_section=target) self.assertEqual(target.examples[0].text, '<em>example2</em>') self.assertEqual(target.examples[1].text, '<em>example</em>')
def test_merge_into_section_before_sanity(self): target = Section('The title\n' 'The description\n' 'Styleguide a.b') target.parse() source = Section('Title: Title prefix\n' 'Extra description\n' 'StyleguideExtendBefore a.b') source.parse() source.merge_into_section(target_section=target) self.assertEqual(target.reference, 'a.b') self.assertEqual(target.title, 'Title prefix The title') self.assertEqual(target.description, 'Extra description\n\nThe description')
def test_merge_into_section_after_multiple_examples(self): target = Section( 'The title\nExample:\n <em>example</em>\nStyleguide a.b') target.parse() source = Section('Example:\n <em>example2</em>\n' 'Example:\n <em>example3</em>\n' 'StyleguideExtendAfter a.b') source.parse() source.merge_into_section(target_section=target) self.assertEqual(target.examples[0].text, '<em>example</em>') self.assertEqual(target.examples[1].text, '<em>example2</em>') self.assertEqual(target.examples[2].text, '<em>example3</em>')
def test_merge_into_section_after_sanity(self): target = Section('The title\n' 'The description\n' 'Styleguide a.b') target.parse() source = Section('Title: Title suffix\n' 'Extra description\n' 'StyleguideExtendAfter a.b') source.parse() source.merge_into_section(target_section=target) self.assertEqual(target.reference, 'a.b') self.assertEqual(target.title, 'The title Title suffix') self.assertEqual(target.description, 'The description\n\nExtra description')