Ejemplo n.º 1
0
    def test_link_processing(self):
        import_support = TracImportSupport()
        import_support.get_slug_by_id = lambda ticket, comment: '123'
        cases = {
                'test link [[2496]](http://testlink.com)':
                "test link [\[2496\]](http://testlink.com)",

                'test ticket ([#201](http://site.net/apps/trac/project/ticket/201))':
                'test ticket ([#201](201))',

                'Replying to [someuser](http://site.net/apps/trac/project/ticket/204#comment:1)':
                'Replying to [someuser](204/#123)',

                '**description** modified ([diff](http://site.net/apps/trac/project/ticket/205?action=diff&version=1))':
                '**description** modified ([diff](205))',

                'Fixed in [r1000](http://site.net/apps/trac/project/changeset/1000)':
                'Fixed in [r1000](r1000)',

                '[[Double brackets]](1) the [[whole way]](2).':
                '[\[Double brackets\]](1) the [\[whole way\]](2).',

                '#200 unchanged':
                '#200 unchanged',
            }
        for input, expected in cases.items():
            actual = import_support.link_processing(input)
            self.assertEqual(actual, expected)
Ejemplo n.º 2
0
    def test_link_processing(self):
        import_support = TracImportSupport()
        import_support.get_slug_by_id = lambda ticket, comment: '123'
        result = import_support.link_processing('''\
                test link [[2496]](http://testlink.com)
                test ticket ([#201](http://sourceforge.net/apps/trac/sourceforge/ticket/201))
                Replying to [someuser](http://sourceforge.net/apps/trac/sourceforge/ticket/204#comment:1)
                #200 unchanged''')

        assert "test link [\[2496\]](http://testlink.com)" in result
        assert 'test ticket ([#201](201))' in result
        assert 'Replying to [someuser](204/#123)' in result
        assert '#200 unchanged' in result, result
Ejemplo n.º 3
0
    def test_link_processing(self):
        import_support = TracImportSupport()
        import_support.get_slug_by_id = lambda ticket, comment: '123'
        result = import_support.link_processing('''\
                test link [[2496]](http://testlink.com)
                test ticket ([#201](http://sourceforge.net/apps/trac/sourceforge/ticket/201))
                Replying to [someuser](http://sourceforge.net/apps/trac/sourceforge/ticket/204#comment:1)
                #200 unchanged''')

        assert "test link [\[2496\]](http://testlink.com)" in result
        assert 'test ticket ([#201](201))' in result
        assert 'Replying to [someuser](204/#123)' in result
        assert '#200 unchanged' in result, result
Ejemplo n.º 4
0
 def test_list(self):
     from allura.scripts.trac_export import TracExport, DateJSONEncoder
     csv_fp = open(os.path.dirname(__file__) + '/data/test-list.csv')
     html_fp = open(os.path.dirname(__file__) + '/data/test-list.html')
     with patch.object(TracExport,
                       'next_ticket_ids',
                       return_value=[(390, {})]):
         te = TracExport('url', do_attachments=False)
         te.exhausted = True
         te.csvopen = lambda s: csv_fp
     with patch('allura.scripts.trac_export.urlopen', return_value=html_fp):
         json_data = {
             'class': 'PROJECT',
             'trackers': {
                 'default': {
                     'artifacts': list(te)
                 }
             },
         }
     TracImportSupport().perform_import(
         json.dumps(json_data, cls=DateJSONEncoder), '{"user_map": {}}')
     ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                  ticket_num=390)
     self.assertIn('To reproduce:  \n\\- open an mzML file',
                   ticket.description)
     self.assertIn('duplicate of:  \n\\- [#316](316)',
                   ticket.discussion_thread.find_posts()[0].text)
     self.assertIn('will crash TOPPView.', ticket.description)
Ejemplo n.º 5
0
    def test_slug(self):
        doc_text = open(os.path.dirname(__file__) + '/data/trac-export.json').read()

        TracImportSupport().perform_import(doc_text,
                '{"user_map": {"hinojosa4": "test-admin", "ma_boehm": "test-user"}}')

        ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                    ticket_num=204)
        comments = ticket.discussion_thread.post_class().query.find(dict(
            discussion_id=ticket.discussion_thread.discussion_id,
            thread_id=ticket.discussion_thread._id,
            status={'$in': ['ok', 'pending']})).sort('timestamp').all()

        import_support = TracImportSupport()
        self.assertEqual(import_support.get_slug_by_id('204', '1'), comments[0].slug)
        self.assertEqual(import_support.get_slug_by_id('204', '2'), comments[1].slug)
Ejemplo n.º 6
0
    def test_slug(self):
        doc_text = open(os.path.dirname(__file__) +
                        '/data/trac-export.json').read()

        TracImportSupport().perform_import(
            doc_text,
            '{"user_map": {"hinojosa4": "test-admin", "ma_boehm": "test-user"}}'
        )

        ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                     ticket_num=204)
        comments = ticket.discussion_thread.post_class().query.find(
            dict(discussion_id=ticket.discussion_thread.discussion_id,
                 thread_id=ticket.discussion_thread._id,
                 status={'$in': ['ok', 'pending']})).sort('timestamp').all()

        import_support = TracImportSupport()
        self.assertEqual(import_support.get_slug_by_id('204', '1'),
                         comments[0].slug)
        self.assertEqual(import_support.get_slug_by_id('204', '2'),
                         comments[1].slug)
Ejemplo n.º 7
0
 def test_link_processing(self):
     import_support = TracImportSupport()
     import_support.get_slug_by_id = lambda ticket, comment: '123'
     cases = {
         'test link [[2496]](http://testlink.com)':
         "test link [\[2496\]](http://testlink.com)",
         'test ticket ([#201](http://site.net/apps/trac/project/ticket/201))':
         'test ticket ([#201](201))',
         'Replying to [someuser](http://site.net/apps/trac/project/ticket/204#comment:1)':
         'Replying to [someuser](204/#123)',
         '**description** modified ([diff](http://site.net/apps/trac/project/ticket/205?action=diff&version=1))':
         '**description** modified ([diff](205))',
         'Fixed in [r1000](http://site.net/apps/trac/project/changeset/1000)':
         'Fixed in [r1000](r1000)',
         '[[Double brackets]](1) the [[whole way]](2).':
         '[\[Double brackets\]](1) the [\[whole way\]](2).',
         '#200 unchanged':
         '#200 unchanged',
     }
     for input, expected in cases.items():
         actual = import_support.link_processing(input)
         self.assertEqual(actual, expected)
Ejemplo n.º 8
0
    def test_links(self):
        doc_text = open(os.path.dirname(__file__) +
                        '/data/trac-export.json').read()

        TracImportSupport().perform_import(
            doc_text,
            '{"user_map": {"hinojosa4": "test-admin", "ma_boehm": "test-user"}}'
        )

        r = self.app.get('/p/test/bugs/204/')
        ticket = TM.Ticket.query.get(app_config_id=c.app.config._id,
                                     ticket_num=204)
        slug = ticket.discussion_thread.post_class().query.find(
            dict(discussion_id=ticket.discussion_thread.discussion_id,
                 thread_id=ticket.discussion_thread._id,
                 status={'$in': ['ok',
                                 'pending']})).sort('timestamp').all()[0].slug

        assert '[test comment](204/#%s)' % slug in r
        assert 'test link [\[2496\]](http://testlink.com)' in r
        assert 'test ticket ([#201](201))' in r