예제 #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)
예제 #2
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)
예제 #3
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)
예제 #4
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
예제 #5
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
예제 #6
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)