示例#1
0
    def test_create_bug_that_has_another_date_format(self):
        tbp = TracBugParser('http://dsource.org/projects/tango/ticket/1939')
        tbp.bug_csv = {
            'cc': '',
            'component': 'Documentation',
            'description':
            "tango.core.Memory.GC.monitor() is documented incorrectly. It just duplicates previous function documentation. At least in Kai. Can't see current trunk Memory module for some reason.\\r\\n",
            'id': '1939',
            'keywords': 'GC.monitor',
            'milestone': 'Documentation',
            'owner': 'community',
            'priority': 'trivial',
            'reporter': '~Gh0sT~',
            'resolution': '',
            'status': 'new',
            'summary':
            'tango.core.Memory.GC.monitor() is documented incorrectly',
            'type': 'defect',
            'version': '0.99.9 Kai',
        }

        cached_html_filename = os.path.join(HERE, 'sample-data',
                                            'dsource-1939')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm4)
        wanted_date = printable_datetime(
            datetime.datetime(2010, 6, 19, 8, 15, 37))
        self.assertEqual(wanted_date, got['date_reported'])
        self.assertEqual(wanted_date, got['last_touched'])
示例#2
0
    def test_create_bug_with_link_in_reported_by_field(self):
        tbp = TracBugParser('https://code.djangoproject.com/query?id=18937')

        cached_csv_filename = os.path.join(HERE, 'sample-data', 'django-trac-18937.csv')
        tbp.set_bug_csv_data(unicode(
            open(cached_csv_filename).read(), 'utf-8'))

        cached_html_filename = os.path.join(HERE, 'sample-data', 'django-trac-18937.html')
        tbp.set_bug_html_data(unicode(
            open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm4)
        del got['last_polled']

        wanted = {
            '_project_name': 'Tango',
            'as_appears_in_distribution': '',
            'canonical_bug_link': 'https://code.djangoproject.com/query?id=18937',
            'concerns_just_documentation': False,
            'date_reported': printable_datetime(
                datetime.datetime(2012, 9, 10, 3, 17, 54)),
            'description': u'Add a PKG-INFO file as fitting with [http://www.python.org/dev/peps/pep-0345/ PEP 345].\r\rSee [http://blog.ziade.org/2012/09/10/dear-django-help-python-packaging/ this blog post] for reference.\r\rSeems to me we can add this metadata file without too much difficulty and make new packaging happy :D\r\r',
            'good_for_newcomers': False,
            'importance': '',
            'last_touched': printable_datetime(
                datetime.datetime(2012, 9, 10, 3, 27, 13)),
            'looks_closed': False,
            'people_involved': 3,
            'status': 'new',
            'submitter_realname': '',
            'submitter_username': '******',
            'title': 'Use modern Python packaging metadata standard (1.2, PEP 345)',
        }
        self.assertEqual(wanted, got)
示例#3
0
    def test_get_opened_date_with_timeline_class(self):
        '''This test case is for input that has the reported date of the bug inside 
        an a tag with class "timeline" and the div with "date" class is missing'''
        tbp = TracBugParser(
            bug_url='https://projects.forum.nokia.com/ndg/ticket/92')

        # Add data to avoid the network hit
        # (This is a file you can get by calling 'wget' on the above ticket URL.)
        # (You might have to add --no-check-certificate to override the certificate common name error)
        cached_html_filename = os.path.join(HERE, 'sample-data',
                                            'ndg-ticket-92')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        # This CSV data comes from visiting
        # https://projects.forum.nokia.com/ndg/ticket/92 and clicking
        # "Comma-delimited text" at the bottom.
        tbp.set_bug_csv_data(
            open(os.path.join(HERE, 'sample-data',
                              'ndg-ticket-92.csv')).read())

        # Provide a fake "tracker model", which is a little bit of data that
        # corresponds to information about the open source project in question
        # and how its bug tracker is configured.
        tm = TrackerModel()

        # Now, actually look at the data returned by the BugParser object
        # and verify its output through assertions.
        returned_data = tbp.get_parsed_data_dict(tm)
        assert returned_data['title'] == 'Enhanced GPS setting'
        assert returned_data['date_reported']
示例#4
0
    def test_create_bug_that_has_another_date_format(self):
        tbp = TracBugParser('http://dsource.org/projects/tango/ticket/1939')
        tbp.bug_csv = {
            'cc': '',
            'component': 'Documentation',
            'description': "tango.core.Memory.GC.monitor() is documented incorrectly. It just duplicates previous function documentation. At least in Kai. Can't see current trunk Memory module for some reason.\\r\\n",
            'id': '1939',
            'keywords': 'GC.monitor',
            'milestone': 'Documentation',
            'owner': 'community',
            'priority': 'trivial',
            'reporter': '~Gh0sT~',
            'resolution': '',
            'status': 'new',
            'summary': 'tango.core.Memory.GC.monitor() is documented incorrectly',
            'type': 'defect',
            'version': '0.99.9 Kai',
            }

        cached_html_filename = os.path.join(HERE, 'sample-data', 'dsource-1939')
        tbp.set_bug_html_data(unicode(
            open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm4)
        wanted_date = printable_datetime(
            datetime.datetime(2010, 6, 19, 8, 15, 37))
        self.assertEqual(wanted_date, got['date_reported'])
        self.assertEqual(wanted_date, got['last_touched'])
示例#5
0
    def test_create_bug_that_has_new_date_format(self):
        tbp = TracBugParser('http://trac.edgewall.org/ticket/3275')
        tbp.bug_csv = {
                  'description': u"Hi\r\n\r\nWhen embedding sourcecode in wiki pages using the {{{-Makro, I would sometimes like to have line numbers displayed. This would make it possible to reference some lines in a text, like: \r\n\r\n''We got some c-sourcecode here, in line 1, a buffer is allocated, in line 35, some data is copied to the buffer without checking the size of the data...''\r\n\r\nThe svn browser shows line numbers, so I hope this will not be so difficult.",
                  'status': 'new',
                  'keywords': '',
                  'summary': 'Show line numbers when embedding source code in wiki pages',
                  'priority': '',
                  'reporter': 'erik@\xe2\x80\xa6',
                  'id': '3275'}
        cached_html_filename = os.path.join(HERE, 'sample-data', 'trac-3275.html')
        tbp.set_bug_html_data(unicode(
            open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm2)
        del got['last_polled']
        wanted = {'status': 'new',
                  'as_appears_in_distribution': u'',
                  'description': u"Hi\r\n\r\nWhen embedding sourcecode in wiki pages using the {{{-Makro, I would sometimes like to have line numbers displayed. This would make it possible to reference some lines in a text, like: \r\n\r\n''We got some c-sourcecode here, in line 1, a buffer is allocated, in line 35, some data is copied to the buffer without checking the size of the data...''\r\n\r\nThe svn browser shows line numbers, so I hope this will not be so difficult.",
                  'importance': '',
                  'canonical_bug_link': 'http://trac.edgewall.org/ticket/3275',
                  'date_reported': printable_datetime(
                datetime.datetime(2006, 6, 16, 15, 1, 52)),
                  'submitter_realname': '',
                  'title': 'Show line numbers when embedding source code in wiki pages',
                  'people_involved': 3,
                  'last_touched': printable_datetime(
                datetime.datetime(2010, 11, 26, 13, 45, 45)),
                  'submitter_username': '******',
                  'looks_closed': False,
                  'good_for_newcomers': False,
                  'concerns_just_documentation': False,
                  '_project_name': 'Trac',
                  }
        self.assertEqual(wanted, got)
示例#6
0
    def test_get_opened_date_with_timeline_class(self):
        '''This test case is for input that has the reported date of the bug inside 
        an a tag with class "timeline" and the div with "date" class is missing''' 
        tbp = TracBugParser(
                bug_url='https://projects.forum.nokia.com/ndg/ticket/92')

        # Add data to avoid the network hit
        # (This is a file you can get by calling 'wget' on the above ticket URL.)
        # (You might have to add --no-check-certificate to override the certificate common name error)
        cached_html_filename = os.path.join(HERE, 'sample-data',
                'ndg-ticket-92')
        tbp.set_bug_html_data(unicode(
            open(cached_html_filename).read(), 'utf-8'))

        # This CSV data comes from visiting
        # https://projects.forum.nokia.com/ndg/ticket/92 and clicking
        # "Comma-delimited text" at the bottom.
        tbp.set_bug_csv_data(open(os.path.join(HERE, 'sample-data',
                'ndg-ticket-92.csv')).read())

        # Provide a fake "tracker model", which is a little bit of data that
        # corresponds to information about the open source project in question
        # and how its bug tracker is configured.
        tm = TrackerModel()

        # Now, actually look at the data returned by the BugParser object
        # and verify its output through assertions.
        returned_data = tbp.get_parsed_data_dict(tm)
        assert returned_data['title'] == 'Enhanced GPS setting'
        assert returned_data['date_reported']
示例#7
0
    def test_create_bug_that_has_new_date_format(self):
        tbp = TracBugParser('http://trac.edgewall.org/ticket/3275')
        tbp.bug_csv = {
            'description':
            u"Hi\r\n\r\nWhen embedding sourcecode in wiki pages using the {{{-Makro, I would sometimes like to have line numbers displayed. This would make it possible to reference some lines in a text, like: \r\n\r\n''We got some c-sourcecode here, in line 1, a buffer is allocated, in line 35, some data is copied to the buffer without checking the size of the data...''\r\n\r\nThe svn browser shows line numbers, so I hope this will not be so difficult.",
            'status': 'new',
            'keywords': '',
            'summary':
            'Show line numbers when embedding source code in wiki pages',
            'priority': '',
            'reporter': 'erik@\xe2\x80\xa6',
            'id': '3275'
        }
        cached_html_filename = os.path.join(HERE, 'sample-data',
                                            'trac-3275.html')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm2)
        del got['last_polled']
        wanted = {
            'status':
            'new',
            'as_appears_in_distribution':
            u'',
            'description':
            u"Hi\r\n\r\nWhen embedding sourcecode in wiki pages using the {{{-Makro, I would sometimes like to have line numbers displayed. This would make it possible to reference some lines in a text, like: \r\n\r\n''We got some c-sourcecode here, in line 1, a buffer is allocated, in line 35, some data is copied to the buffer without checking the size of the data...''\r\n\r\nThe svn browser shows line numbers, so I hope this will not be so difficult.",
            'importance':
            '',
            'canonical_bug_link':
            'http://trac.edgewall.org/ticket/3275',
            'date_reported':
            printable_datetime(datetime.datetime(2006, 6, 16, 15, 1, 52)),
            'submitter_realname':
            '',
            'title':
            'Show line numbers when embedding source code in wiki pages',
            'people_involved':
            3,
            'last_touched':
            printable_datetime(datetime.datetime(2010, 11, 26, 13, 45, 45)),
            'submitter_username':
            '******',
            'looks_closed':
            False,
            'good_for_newcomers':
            False,
            'concerns_just_documentation':
            False,
            '_project_name':
            'Trac',
        }
        self.assertEqual(wanted, got)
示例#8
0
    def test_create_bug_with_link_in_reported_by_field(self):
        tbp = TracBugParser('https://code.djangoproject.com/query?id=18937')

        cached_csv_filename = os.path.join(HERE, 'sample-data',
                                           'django-trac-18937.csv')
        tbp.set_bug_csv_data(unicode(
            open(cached_csv_filename).read(), 'utf-8'))

        cached_html_filename = os.path.join(HERE, 'sample-data',
                                            'django-trac-18937.html')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm4)
        del got['last_polled']

        wanted = {
            '_project_name':
            'Tango',
            'as_appears_in_distribution':
            '',
            'canonical_bug_link':
            'https://code.djangoproject.com/query?id=18937',
            'concerns_just_documentation':
            False,
            'date_reported':
            printable_datetime(datetime.datetime(2012, 9, 10, 3, 17, 54)),
            'description':
            u'Add a PKG-INFO file as fitting with [http://www.python.org/dev/peps/pep-0345/ PEP 345].\r\rSee [http://blog.ziade.org/2012/09/10/dear-django-help-python-packaging/ this blog post] for reference.\r\rSeems to me we can add this metadata file without too much difficulty and make new packaging happy :D\r\r',
            'good_for_newcomers':
            False,
            'importance':
            '',
            'last_touched':
            printable_datetime(datetime.datetime(2012, 9, 10, 3, 27, 13)),
            'looks_closed':
            False,
            'people_involved':
            3,
            'status':
            'new',
            'submitter_realname':
            '',
            'submitter_username':
            '******',
            'title':
            'Use modern Python packaging metadata standard (1.2, PEP 345)',
        }
        self.assertEqual(wanted, got)
示例#9
0
    def test_create_bug_object_data_dict_more_recent(self):
        tbp = TracBugParser('http://twistedmatrix.com/trac/ticket/4298')
        tbp.bug_csv = {
            'branch': '',
            'branch_author': '',
            'cc': 'thijs_ exarkun',
            'component': 'core',
            'description': "This package hasn't been touched in 4 years which either means it's stable or not being used at all. Let's deprecate it (also see #4111).",
            'id': '4298',
            'keywords': 'easy',
            'launchpad_bug': '',
            'milestone': '',
            'owner': 'djfroofy',
            'priority': 'normal',
            'reporter': 'thijs',
            'resolution': '',
            'status': 'new',
            'summary': 'Deprecate twisted.persisted.journal',
            'type': 'task'}
        cached_html_filename = os.path.join(HERE, 'sample-data', 'twisted-trac-4298-on-2010-04-02.html')
        tbp.set_bug_html_data(unicode(
            open(cached_html_filename).read(), 'utf-8'))

        self.assertEqual(tbp.component, 'core')

        got = tbp.get_parsed_data_dict(self.tm)
        del got['last_polled']
        wanted = {'title': 'Deprecate twisted.persisted.journal',
                  'description': "This package hasn't been touched in 4 years which either means it's stable or not being used at all. Let's deprecate it (also see #4111).",
                  'status': 'new',
                  'importance': 'normal',
                  'people_involved': 3,
                  # FIXME: Need time zone
                  'date_reported': printable_datetime(
                datetime.datetime(2010, 2, 23, 0, 46, 30)),
                  'last_touched': printable_datetime(
                datetime.datetime(2010, 3, 12, 18, 43, 5)),
                  'looks_closed': False,
                  'submitter_username': '******',
                  'submitter_realname': '',
                  'canonical_bug_link': 'http://twistedmatrix.com/trac/ticket/4298',
                  'good_for_newcomers': True,
                  'looks_closed': False,
                  'concerns_just_documentation': False,
                  '_project_name': 'Twisted',
                  'as_appears_in_distribution': '',
                  }
        self.assertEqual(wanted, got)
示例#10
0
    def test_bug_with_difficulty_easy_is_bitesize(self):
        tbp = TracBugParser(
                bug_url='http://hackage.haskell.org/trac/ghc/ticket/4268')

        cached_html_filename = os.path.join(HERE, 'sample-data',
                'ghc-trac-4268.html')
        tbp.set_bug_html_data(unicode(
            open(cached_html_filename).read(), 'utf-8'))

        cached_csv_filename = os.path.join(HERE, 'sample-data',
                'ghc-trac-4268.csv')
        tbp.set_bug_csv_data(open(cached_csv_filename).read())

        tm = HaskellTrackerModel()

        returned_data = tbp.get_parsed_data_dict(tm)
        assert returned_data['good_for_newcomers'], '''The bug is considered
示例#11
0
    def test_bug_with_difficulty_easy_is_bitesize(self):
        tbp = TracBugParser(
            bug_url='http://hackage.haskell.org/trac/ghc/ticket/4268')

        cached_html_filename = os.path.join(HERE, 'sample-data',
                                            'ghc-trac-4268.html')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        cached_csv_filename = os.path.join(HERE, 'sample-data',
                                           'ghc-trac-4268.csv')
        tbp.set_bug_csv_data(open(cached_csv_filename).read())

        tm = HaskellTrackerModel()

        returned_data = tbp.get_parsed_data_dict(tm)
        assert returned_data['good_for_newcomers'], '''The bug is considered
示例#12
0
    def test_bug_parser(self):
        ### As an aside:
        # TracBugParser is amusing, as it pulls data from two different sources.
        # 1. Data pulled from the Trac API, which is stored for the parser's
        #    benefit in csv_data.
        # 2. Data that must be scraped from the Trac web app, since the API
        #    doesn't expose everything. This gets stored in html_data.

        # In this test, we provide versions of that data that we downloaded
        # in the past so that we can make this test run fast and reliably.
        # By providing the data here, we permit the test to run without
        # accessing the network.

        # Create a new TracBugParser that is aware of the URL it refers to
        tbp = TracBugParser(
            bug_url='http://twistedmatrix.com/trac/ticket/4298')

        # Add data to avoid the network hit
        # (This is a file you can get by calling 'wget' on the above ticket URL.)
        cached_html_filename = os.path.join(
            HERE, 'sample-data', 'twisted-trac-4298-on-2010-04-02.html')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        # This CSV data comes from visiting
        # http://twistedmatrix.com/trac/ticket/4298 and clicking
        # "Comma-delimited text" at the bottom.
        tbp.set_bug_csv_data(
            open(
                os.path.join(HERE, 'sample-data',
                             'twisted-trac-4298-csv-export')).read())

        # Provide a fake "tracker model", which is a little bit of data that
        # corresponds to information about the open source project in question
        # and how its bug tracker is configured.
        tm = TrackerModel()

        # Now, actually look at the data returned by the BugParser object
        # and verify its output through assertions.
        returned_data = tbp.get_parsed_data_dict(tm)
        assert returned_data['title'] == 'Deprecate twisted.persisted.journal'
        assert returned_data['good_for_newcomers']
示例#13
0
    def test_bug_parser(self):
        ### As an aside:
        # TracBugParser is amusing, as it pulls data from two different sources.
        # 1. Data pulled from the Trac API, which is stored for the parser's
        #    benefit in csv_data.
        # 2. Data that must be scraped from the Trac web app, since the API
        #    doesn't expose everything. This gets stored in html_data.

        # In this test, we provide versions of that data that we downloaded
        # in the past so that we can make this test run fast and reliably.
        # By providing the data here, we permit the test to run without
        # accessing the network.

        # Create a new TracBugParser that is aware of the URL it refers to
        tbp = TracBugParser(
            bug_url='http://twistedmatrix.com/trac/ticket/4298')

        # Add data to avoid the network hit
        # (This is a file you can get by calling 'wget' on the above ticket URL.)
        cached_html_filename = os.path.join(
            HERE, 'sample-data', 'twisted-trac-4298-on-2010-04-02.html')
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        # This CSV data comes from visiting
        # http://twistedmatrix.com/trac/ticket/4298 and clicking
        # "Comma-delimited text" at the bottom.
        tbp.set_bug_csv_data(
            open(
                os.path.join(HERE, 'sample-data',
                             'twisted-trac-4298-csv-export')).read())

        # Provide a fake "tracker model", which is a little bit of data that
        # corresponds to information about the open source project in question
        # and how its bug tracker is configured.
        tm = TrackerModel()

        # Now, actually look at the data returned by the BugParser object
        # and verify its output through assertions.
        returned_data = tbp.get_parsed_data_dict(tm)
        assert returned_data['title'] == 'Deprecate twisted.persisted.journal'
        assert returned_data['good_for_newcomers']
示例#14
0
    def test_create_bug_that_lacks_modified_date_and_uses_owned_by_instead_of_assigned_to(
            self):
        tbp = TracBugParser('http://twistedmatrix.com/trac/ticket/4298')
        tbp.bug_csv = {
            'branch': '',
            'branch_author': '',
            'cc': 'thijs_ exarkun',
            'component': 'core',
            'description':
            "This package hasn't been touched in 4 years which either means it's stable or not being used at all. Let's deprecate it (also see #4111).",
            'id': '4298',
            'keywords': 'easy',
            'launchpad_bug': '',
            'milestone': '',
            'owner': 'djfroofy',
            'priority': 'normal',
            'reporter': 'thijs',
            'resolution': '',
            'status': 'new',
            'summary': 'Deprecate twisted.persisted.journal',
            'type': 'task'
        }
        cached_html_filename = os.path.join(
            HERE, 'sample-data',
            'twisted-trac-4298-without-modified-using-owned-instead-of-assigned.html'
        )
        tbp.set_bug_html_data(
            unicode(open(cached_html_filename).read(), 'utf-8'))

        got = tbp.get_parsed_data_dict(self.tm)
        del got['last_polled']
        wanted = {
            'title':
            'Deprecate twisted.persisted.journal',
            'description':
            "This package hasn't been touched in 4 years which either means it's stable or not being used at all. Let's deprecate it (also see #4111).",
            'status':
            'new',
            'importance':
            'normal',
            'people_involved':
            4,
            # FIXME: Need time zone
            'date_reported':
            printable_datetime(datetime.datetime(2010, 2, 22, 19, 46, 30)),
            'last_touched':
            printable_datetime(datetime.datetime(2010, 2, 22, 19, 46, 30)),
            'looks_closed':
            False,
            'submitter_username':
            '******',
            'submitter_realname':
            '',
            'canonical_bug_link':
            'http://twistedmatrix.com/trac/ticket/4298',
            'good_for_newcomers':
            True,
            'looks_closed':
            False,
            'concerns_just_documentation':
            False,
            '_project_name':
            'Twisted',
            'as_appears_in_distribution':
            '',
        }
        self.assertEqual(wanted, got)