Ejemplo n.º 1
0
    def test_docbook_parse_sp25_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'spring25doc', 'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.NewDocBookParser')
        print('Syncing Doc')
        sync_doc(pname, dname, release)
        print('Synced Doc')

        document = parse_doc(pname, dname, release, False)

        page = Page.objects.filter(document=document).filter(
            title='Chapter 22. Email').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(11, page.sections.count())

        section = Section.objects.filter(page=page).filter(
            number='22.3.1.1.').all()[0]
        self.assertEqual('22.3.1.1. Attachments', section.title)
        self.assertEqual(78, section.word_count)
        self.assertEqual('22.3.1.', section.parent.number)

        section = Section.objects.filter(page=page).filter(
            number='22.2.').all()[0]
        self.assertEqual('22.2. Usage', section.title)
        self.assertEqual(51, section.word_count)
        self.assertEqual('22.', section.parent.number)
        self.assertTrue(section.parent.parent is None)
Ejemplo n.º 2
0
    def test_maven_parse_joda162_doc_code(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'joda162doc',
            'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.MavenParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, True)
        
        page = Page.objects.filter(document=document).filter(
                title='User Guide').all()[0]

        section = Section.objects.filter(page=page).filter(
                title='Direct access').all()[0]
        self.assertEqual(0, section.title_references.count())
        # Only 2, because small references are not added! Yay!
        self.assertEqual(2, section.code_references.count())
        self.assertEqual(1, section.code_snippets.count())
        
        section = Section.objects.filter(page=page).filter(
                title='Using a MutableDateTime').all()[0]
        self.assertEqual(1, section.title_references.count())
        # Include the ref in the title too!
        self.assertEqual(2, section.code_references.count())
        self.assertEqual(1, section.code_snippets.count())
Ejemplo n.º 3
0
    def test_docbook_parse_hib3_doc_code(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'hib35doc',
            'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.NewDocBookParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, True)
        
        page = Page.objects.filter(document=document).filter(
                title='Chapter 12. Transactions and Concurrency').all()[0]

        section = Section.objects.filter(page=page).filter(
                number='12.3.4.').all()[0]
        self.assertEqual(0, section.title_references.count())
        self.assertEqual(13, section.code_references.count())
        self.assertEqual(0, section.code_snippets.count())

        section = Section.objects.filter(page=page).filter(
                number='12.3.3.').all()[0]
        self.assertEqual(0, section.title_references.count())
        self.assertEqual(12, section.code_references.count())
        self.assertEqual(1, section.code_snippets.count())
Ejemplo n.º 4
0
    def test_maven_parse_joda162_doc_code(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'joda162doc', 'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.MavenParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, True)

        page = Page.objects.filter(document=document).filter(
            title='User Guide').all()[0]

        section = Section.objects.filter(page=page).filter(
            title='Direct access').all()[0]
        self.assertEqual(0, section.title_references.count())
        # Only 2, because small references are not added! Yay!
        self.assertEqual(2, section.code_references.count())
        self.assertEqual(1, section.code_snippets.count())

        section = Section.objects.filter(page=page).filter(
            title='Using a MutableDateTime').all()[0]
        self.assertEqual(1, section.title_references.count())
        # Include the ref in the title too!
        self.assertEqual(2, section.code_references.count())
        self.assertEqual(1, section.code_snippets.count())
Ejemplo n.º 5
0
    def test_docbook_parse_hib3_doc_code(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'hib35doc', 'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.NewDocBookParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, True)

        page = Page.objects.filter(document=document).filter(
            title='Chapter 12. Transactions and Concurrency').all()[0]

        section = Section.objects.filter(page=page).filter(
            number='12.3.4.').all()[0]
        self.assertEqual(0, section.title_references.count())
        self.assertEqual(13, section.code_references.count())
        self.assertEqual(0, section.code_snippets.count())

        section = Section.objects.filter(page=page).filter(
            number='12.3.3.').all()[0]
        self.assertEqual(0, section.title_references.count())
        self.assertEqual(12, section.code_references.count())
        self.assertEqual(1, section.code_snippets.count())
Ejemplo n.º 6
0
    def test_docbook_parse_ht4_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'httpclient402doc',
                                'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.NewDocBookParser')
        sync_doc(pname, dname, release)
        document = parse_doc(pname, dname, release, False)

        page = Page.objects.filter(document=document).filter(
            title='Chapter 2. Connection management').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(23, page.sections.count())

        section = Section.objects.filter(page=page).filter(
            number='2.3.1.').all()[0]
        self.assertEqual('2.3.1. Route computation', section.title)
        self.assertEqual(182, section.word_count)
        self.assertEqual('2.3.', section.parent.number)

        # With code snippets:
        section = Section.objects.filter(page=page).filter(
            number='2.5.').all()[0]
        self.assertEqual('2.5. Socket factories', section.title)
        self.assertEqual(110, section.word_count)
        self.assertEqual('2.', section.parent.number)
        self.assertTrue(section.parent.parent is None)
Ejemplo n.º 7
0
    def test_docbook_parse_ht4_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'httpclient402doc',
            'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.NewDocBookParser')
        sync_doc(pname, dname, release)
        document = parse_doc(pname, dname, release, False)
        
        page = Page.objects.filter(document=document).filter(
                title='Chapter 2. Connection management').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(23, page.sections.count())

        section = Section.objects.filter(page=page).filter(
                number='2.3.1.').all()[0]
        self.assertEqual('2.3.1. Route computation', section.title)
        self.assertEqual(182, section.word_count)
        self.assertEqual('2.3.', section.parent.number)

        # With code snippets:
        section = Section.objects.filter(page=page).filter(
                number='2.5.').all()[0]
        self.assertEqual('2.5. Socket factories', section.title)
        self.assertEqual(110, section.word_count)
        self.assertEqual('2.', section.parent.number)
        self.assertTrue(section.parent.parent is None)
Ejemplo n.º 8
0
 def test_sync_doc_remote(self):
     pname = 'project1'
     release = '3.0'
     dname = 'manual'
     create_doc_local(pname, dname, release,
             'doc.syncer.generic_syncer.SingleURLSyncer',
             'http://hc.apache.org/httpcomponents-client-ga/tutorial/html/index.html')
     sync_doc(pname, dname, release)
     doc_key = dname + release
     model = load_model(pname, DOC_PATH, doc_key)
     self.assertEqual(9, len(model.pages))
     for page_key in model.pages:
         path = urlparse(page_key).path
         self.assertTrue(os.path.exists(path))
Ejemplo n.º 9
0
 def test_sync_doc_remote(self):
     pname = 'project1'
     release = '3.0'
     dname = 'manual'
     create_doc_local(
         pname, dname, release, 'doc.syncer.generic_syncer.SingleURLSyncer',
         'http://hc.apache.org/httpcomponents-client-ga/tutorial/html/index.html'
     )
     sync_doc(pname, dname, release)
     doc_key = dname + release
     model = load_model(pname, DOC_PATH, doc_key)
     self.assertEqual(9, len(model.pages))
     for page_key in model.pages:
         path = urlparse(page_key).path
         self.assertTrue(os.path.exists(path))
Ejemplo n.º 10
0
 def test_sync_doc_local(self):
     pname = 'project1'
     release = '3.0'
     dname = 'manual'
     test_doc = os.path.join(settings.TESTDATA, 'httpclient402doc',
         'index.html')
     test_doc = os.path.normpath(test_doc)
     create_doc_local(pname, dname, release,
             'doc.syncer.generic_syncer.SingleURLSyncer',
             'file://' + test_doc) 
     sync_doc(pname, dname, release)
     doc_key = dname + release
     model = load_model(pname, DOC_PATH, doc_key)
     self.assertEqual(8, len(model.pages))
     for page_key in model.pages:
         path = urlparse(page_key).path
         self.assertTrue(os.path.exists(path))
Ejemplo n.º 11
0
 def test_sync_doc_local(self):
     pname = 'project1'
     release = '3.0'
     dname = 'manual'
     test_doc = os.path.join(settings.TESTDATA, 'httpclient402doc',
                             'index.html')
     test_doc = os.path.normpath(test_doc)
     create_doc_local(pname, dname, release,
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'file://' + test_doc)
     sync_doc(pname, dname, release)
     doc_key = dname + release
     model = load_model(pname, DOC_PATH, doc_key)
     self.assertEqual(8, len(model.pages))
     for page_key in model.pages:
         path = urlparse(page_key).path
         self.assertTrue(os.path.exists(path))
Ejemplo n.º 12
0
    def test_maven_parse_joda162_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'joda162doc',
            'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.MavenParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, False)
        
        page = Page.objects.filter(document=document).filter(
                title='User Guide').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(35, page.sections.count())

        section = Section.objects.filter(page=page).filter(
                title='Direct access').all()[0]
        self.assertEqual('Direct access', section.title)
        self.assertEqual(110, section.word_count)
        self.assertEqual('', section.number)
        self.assertEqual('Input and Output', section.parent.title)
        self.assertEqual(162, section.parent.word_count)

        section = Section.objects.filter(page=page).filter(
                title='Advanced features').all()[0]
        self.assertEqual('Advanced features', section.title)
        self.assertEqual(2, section.word_count)
        self.assertTrue(section.parent is None)
Ejemplo n.º 13
0
    def test_maven_parse_htclient_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'httpclient31doc',
            'userguide.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.MavenParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, False)
        
        page = Page.objects.filter(document=document).filter(
                title='HttpClient exception handling guide').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(22, page.sections.count())

        section = Section.objects.filter(page=page).filter(
                title='Idempotent methods').all()[0]
        self.assertEqual('Idempotent methods', section.title)
        self.assertEqual(113, section.word_count)
        self.assertEqual('', section.number)
        self.assertEqual('HTTP transport safety', section.parent.title)

        section = Section.objects.filter(page=page).filter(
                title='Custom exception handler').all()[0]
        self.assertEqual('Custom exception handler', section.title)
        self.assertEqual('', section.number)
        self.assertEqual(132, section.word_count)
        self.assertTrue(section.parent is None)
Ejemplo n.º 14
0
    def test_maven_parse_htclient_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'httpclient31doc',
                                'userguide.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.MavenParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, False)

        page = Page.objects.filter(document=document).filter(
            title='HttpClient exception handling guide').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(22, page.sections.count())

        section = Section.objects.filter(page=page).filter(
            title='Idempotent methods').all()[0]
        self.assertEqual('Idempotent methods', section.title)
        self.assertEqual(113, section.word_count)
        self.assertEqual('', section.number)
        self.assertEqual('HTTP transport safety', section.parent.title)

        section = Section.objects.filter(page=page).filter(
            title='Custom exception handler').all()[0]
        self.assertEqual('Custom exception handler', section.title)
        self.assertEqual('', section.number)
        self.assertEqual(132, section.word_count)
        self.assertTrue(section.parent is None)
Ejemplo n.º 15
0
    def test_docbook_parse_hib3_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'hib35doc',
            'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.NewDocBookParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, False)
        
        page = Page.objects.filter(document=document).filter(
                title='Chapter 12. Transactions and Concurrency').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(18, page.sections.count())

        section = Section.objects.filter(page=page).filter(
                number='12.3.4.').all()[0]
        self.assertEqual('12.3.4. Customizing automatic versioning', section.title)
        self.assertTrue(276, section.word_count)
        self.assertEqual('12.3.', section.parent.number)

        section = Section.objects.filter(page=page).filter(
                number='12.5.').all()[0]
        self.assertEqual('12.5. Connection release modes', section.title)
        self.assertEqual(371, section.word_count)
        self.assertEqual('12.', section.parent.number)
        self.assertTrue(section.parent.parent is None)
Ejemplo n.º 16
0
    def test_maven_parse_joda162_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'joda162doc', 'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.MavenParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, False)

        page = Page.objects.filter(document=document).filter(
            title='User Guide').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(35, page.sections.count())

        section = Section.objects.filter(page=page).filter(
            title='Direct access').all()[0]
        self.assertEqual('Direct access', section.title)
        self.assertEqual(110, section.word_count)
        self.assertEqual('', section.number)
        self.assertEqual('Input and Output', section.parent.title)
        self.assertEqual(162, section.parent.word_count)

        section = Section.objects.filter(page=page).filter(
            title='Advanced features').all()[0]
        self.assertEqual('Advanced features', section.title)
        self.assertEqual(2, section.word_count)
        self.assertTrue(section.parent is None)
Ejemplo n.º 17
0
    def test_docbook_parse_hib3_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'hib35doc', 'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                         'doc.syncer.generic_syncer.SingleURLSyncer',
                         'file://' + test_doc)
        create_doc_db('project1', 'manual', '3.0', '',
                      'doc.syncer.generic_syncer.SingleURLSyncer',
                      'doc.parser.common_parsers.NewDocBookParser')
        print('Syncing doc')
        sync_doc(pname, dname, release)
        print('Synced doc')

        document = parse_doc(pname, dname, release, False)

        page = Page.objects.filter(document=document).filter(
            title='Chapter 12. Transactions and Concurrency').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(18, page.sections.count())

        section = Section.objects.filter(page=page).filter(
            number='12.3.4.').all()[0]
        self.assertEqual('12.3.4. Customizing automatic versioning',
                         section.title)
        self.assertTrue(276, section.word_count)
        self.assertEqual('12.3.', section.parent.number)

        section = Section.objects.filter(page=page).filter(
            number='12.5.').all()[0]
        self.assertEqual('12.5. Connection release modes', section.title)
        self.assertEqual(371, section.word_count)
        self.assertEqual('12.', section.parent.number)
        self.assertTrue(section.parent.parent is None)
Ejemplo n.º 18
0
    def test_docbook_parse_sp25_doc(self):
        pname = 'project1'
        release = '3.0'
        dname = 'manual'
        test_doc = os.path.join(settings.TESTDATA, 'spring25doc',
            'index.html')
        test_doc = os.path.normpath(test_doc)
        create_doc_local(pname, dname, release,
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'file://' + test_doc) 
        create_doc_db('project1', 'manual', '3.0', '',
                'doc.syncer.generic_syncer.SingleURLSyncer',
                'doc.parser.common_parsers.NewDocBookParser')
        print('Syncing Doc')
        sync_doc(pname, dname, release)
        print('Synced Doc')

        document = parse_doc(pname, dname, release, False)
        
        page = Page.objects.filter(document=document).filter(
                title='Chapter 22. Email').all()[0]
        self.assertEqual('/html/body', page.xpath)
        self.assertEqual(11, page.sections.count())

        section = Section.objects.filter(page=page).filter(
                number='22.3.1.1.').all()[0]
        self.assertEqual('22.3.1.1. Attachments', section.title)
        self.assertEqual(78, section.word_count)
        self.assertEqual('22.3.1.', section.parent.number)

        section = Section.objects.filter(page=page).filter(
                number='22.2.').all()[0]
        self.assertEqual('22.2. Usage', section.title)
        self.assertEqual(51, section.word_count)
        self.assertEqual('22.', section.parent.number)
        self.assertTrue(section.parent.parent is None)
Ejemplo n.º 19
0
 def handle_noargs(self, **options):
     pname = smart_decode(options.get('pname'))
     dname = smart_decode(options.get('dname'))
     release = smart_decode(options.get('release'))
     sync_doc(pname, dname, release)