def test_doc_differ(self): doc1 = create_doc_db('project1', 'manual', '3.0', '', 'foo.syncer', 'foo.parser') doc2 = create_doc_db('project1', 'manual', '3.1', '', 'foo.syncer', 'foo.parser') page1 = Page(document=doc1, title='Chapter 1. Element Reconstruction') page1.save() page2 = Page(document=doc1, title='Chapter 2. On the FooBart Method') page2.save() page3 = Page(document=doc1, title='Chapter 3. Mapping Inheritance and MetaData') page3.save() page4 = Page(document=doc1, title='Chapter 4. Object Query Language Reference') page4.save() section11 = Section(page=page1, number='1.1', title='1.1 Element Section 1') section11.save() section111 = Section(page=page1, parent=section11, number='1.1.1', title='1.1.1. Internal') section111.save() section12 = Section( page=page1, number='1.2', title='1.2 Reconstructing Element', ) section12.save() section121 = Section(page=page1, parent=section12, number='1.2.1', title='1.2.1. Reconstruction SubElement') section121.save() section122 = Section(page=page1, parent=section12, number='1.2.2', title='1.2.2. Internal') section122.save() section21 = Section(page=page2, number='2.1', title='2.1 FooBart Usage') section21.save() section211 = Section(page=page2, parent=section21, number='2.1.1', title='2.1.1. Internal') section211.save() section22 = Section( page=page2, number='2.2', title='2.2 FizzBuzz Example', ) section22.save() section31 = Section(page=page3, number='3.1', title='3.1 Mapping Inheritance') section31.save() section311 = Section(page=page3, parent=section31, number='3.1.1', title='3.1.1. Internal') section311.save() section41 = Section(page=page4, number='4.1', title='4.1 OQL Basics') section41.save() page1 = Page(document=doc2, title='Chapter 1. Element Reconstruction') page1.save() page3 = Page(document=doc2, title='Chapter 2. Mapping Inheritance and MetaData') page3.save() page5 = Page( document=doc2, title='Chapter 3. Saving the World, one Section at a time') page5.save() page4 = Page(document=doc2, title='Chapter 4. Object Query Language Reference') page4.save() section11 = Section(page=page1, number='1.1', title='1.1 Element Section 1') section11.save() section111 = Section(page=page1, parent=section11, number='1.1.1', title='1.1.1. Internal') section111.save() section12 = Section( page=page1, number='1.2', title='1.2 Reconstructing Element', ) section12.save() section122 = Section(page=page1, parent=section12, number='1.2.1', title='1.2.1. Internal') section122.save() section13 = Section(page=page1, number='1.3', title='1.3 New Influences on Element Section 1') section13.save() section131 = Section(page=page1, parent=section13, number='1.3.1', title='1.3.1. Internal') section131.save() section31 = Section(page=page3, number='2.1', title='2.1 Mapping Inheritance') section31.save() section311 = Section(page=page3, parent=section31, number='2.1.1', title='2.1.1. Internal') section311.save() section41 = Section(page=page4, number='4.1', title='4.1 OQL Basics') section41.save() section51 = Section(page=page5, number='3.1', title='3.1 World Hello!') section51.save() ddiff = diff_doc('project1', 'manual', '3.0', '3.1') self.assertEqual(1, ddiff.removed_pages.count()) self.assertEqual(1, ddiff.added_pages.count()) self.assertEqual(4, ddiff.pages_size_from) self.assertEqual(4, ddiff.pages_size_from) for page_match in ddiff.page_matches.all(): print('{0} -> {1} : {2}'.format(page_match.page_from.title, page_match.page_to.title, page_match.confidence)) for section_match in ddiff.section_matches.all(): print('{0} -> {1} : {2}'.format(section_match.section_from.title, section_match.section_to.title, section_match.confidence))
def test_doc_differ(self): doc1 = create_doc_db('project1', 'manual', '3.0', '', 'foo.syncer', 'foo.parser') doc2 = create_doc_db('project1', 'manual', '3.1', '', 'foo.syncer', 'foo.parser') page1 = Page( document=doc1, title='Chapter 1. Element Reconstruction') page1.save() page2 = Page( document=doc1, title='Chapter 2. On the FooBart Method') page2.save() page3 = Page( document=doc1, title='Chapter 3. Mapping Inheritance and MetaData') page3.save() page4 = Page( document=doc1, title='Chapter 4. Object Query Language Reference') page4.save() section11 = Section( page=page1, number='1.1', title='1.1 Element Section 1' ) section11.save() section111 = Section( page=page1, parent=section11, number='1.1.1', title='1.1.1. Internal' ) section111.save() section12 = Section( page=page1, number='1.2', title='1.2 Reconstructing Element', ) section12.save() section121 = Section( page=page1, parent=section12, number='1.2.1', title='1.2.1. Reconstruction SubElement' ) section121.save() section122 = Section( page=page1, parent=section12, number='1.2.2', title='1.2.2. Internal' ) section122.save() section21 = Section( page=page2, number='2.1', title='2.1 FooBart Usage' ) section21.save() section211 = Section( page=page2, parent=section21, number='2.1.1', title='2.1.1. Internal' ) section211.save() section22 = Section( page=page2, number='2.2', title='2.2 FizzBuzz Example', ) section22.save() section31 = Section( page=page3, number='3.1', title='3.1 Mapping Inheritance' ) section31.save() section311 = Section( page=page3, parent=section31, number='3.1.1', title='3.1.1. Internal' ) section311.save() section41 = Section( page=page4, number='4.1', title='4.1 OQL Basics' ) section41.save() page1 = Page( document=doc2, title='Chapter 1. Element Reconstruction') page1.save() page3 = Page( document=doc2, title='Chapter 2. Mapping Inheritance and MetaData') page3.save() page5 = Page( document=doc2, title='Chapter 3. Saving the World, one Section at a time') page5.save() page4 = Page( document=doc2, title='Chapter 4. Object Query Language Reference') page4.save() section11 = Section( page=page1, number='1.1', title='1.1 Element Section 1' ) section11.save() section111 = Section( page=page1, parent=section11, number='1.1.1', title='1.1.1. Internal' ) section111.save() section12 = Section( page=page1, number='1.2', title='1.2 Reconstructing Element', ) section12.save() section122 = Section( page=page1, parent=section12, number='1.2.1', title='1.2.1. Internal' ) section122.save() section13 = Section( page=page1, number='1.3', title='1.3 New Influences on Element Section 1' ) section13.save() section131 = Section( page=page1, parent=section13, number='1.3.1', title='1.3.1. Internal' ) section131.save() section31 = Section( page=page3, number='2.1', title='2.1 Mapping Inheritance' ) section31.save() section311 = Section( page=page3, parent=section31, number='2.1.1', title='2.1.1. Internal' ) section311.save() section41 = Section( page=page4, number='4.1', title='4.1 OQL Basics' ) section41.save() section51 = Section( page=page5, number='3.1', title='3.1 World Hello!' ) section51.save() ddiff = diff_doc('project1', 'manual', '3.0', '3.1') self.assertEqual(1, ddiff.removed_pages.count()) self.assertEqual(1, ddiff.added_pages.count()) self.assertEqual(4, ddiff.pages_size_from) self.assertEqual(4, ddiff.pages_size_from) for page_match in ddiff.page_matches.all(): print('{0} -> {1} : {2}'.format( page_match.page_from.title, page_match.page_to.title, page_match.confidence)) for section_match in ddiff.section_matches.all(): print('{0} -> {1} : {2}'.format( section_match.section_from.title, section_match.section_to.title, section_match.confidence))
def handle_noargs(self, **options): pname = smart_decode(options.get('pname')) dname = smart_decode(options.get('dname')) release1 = smart_decode(options.get('release1')) release2 = smart_decode(options.get('release2')) diff_doc(pname, dname, release1, release2)