Esempio n. 1
0
    def test_regrab_miro_bugs_refreshes_older_bugs_even_when_missing_from_csv(self, mock_csv_maker, mock_xml_opener):
        mock_xml_opener.return_value = open(os.path.join(
            settings.MEDIA_ROOT, 'sample-data', 'miro-2294-2009-08-06.xml'))

        # Situation: Assume there are zero bitesized bugs today.
        # Desire: We re-get old bugs that don't show up in the CSV.

        # Prereq: We have some bug with lame data:
        bug = Bug()
        bug.people_involved = 1
        bug.canonical_bug_link = 'http://bugzilla.pculture.org/show_bug.cgi?id=2294'
        bug.date_reported = datetime.datetime.now()
        bug.last_touched = datetime.datetime.now()
        bug.last_polled = datetime.datetime.now()
        bug.project, _ = Project.objects.get_or_create(name='Miro')
        bug.save()

        # Prepare a fake CSV that is empty
        mock_csv_maker.return_value = StringIO('')

        # Now, do a crawl and notice that we updated the bug even though the CSV is empty
        
        mysite.customs.miro.grab_miro_bugs() # refreshes no bugs since CSV is empty!
        all_bugs = Bug.all_bugs.all()
        self.assertEqual(len(all_bugs), 1)
        bug = all_bugs[0]
        self.assertEqual(bug.people_involved, 5)
Esempio n. 2
0
        tree = lxml.html.document_fromstring(urllib2.urlopen(remote_bug_url).read())
    except urllib2.HTTPError, e:
        if e.code == 404:
            return None
        # otherwise, bubble that crazy error up.
        raise e

    bug = Bug()

    metadata_dict = view_bug_table2dict(tree)

    bug.submitter_username = '' # FIXME: Find an example of this having a value
    bug.submitter_realname = '' # FIXME: Find an example of this having a value
    bug.date_reported = decode_datetime(metadata_dict['Submit Date'])
    bug.last_touched = decode_datetime(metadata_dict['Last Update Date'])
    bug.canonical_bug_link = remote_bug_url
    bug.good_for_newcomers = 'oss-bite-size' in metadata_dict['Keywords']
    bug.status = metadata_dict['State']
    status_number = int(bug.status.split('-')[0])
    bug.looks_closed = (status_number in (8, 10, 11))
    bug.title = metadata_dict['Synopsis']
    bug.importance = '' # No importance, as far as I can tell.

    # For description, just grab the first "message"
    bug.description = metadata_dict['Description']

    # We are always the project called Python.
    bug.project, _ = Project.objects.get_or_create(name='OpenSolaris OS/Net', language='C')

    # How many people participated?
    bug.people_involved = None # This tracker has no idea.