Ejemplo 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)
Ejemplo n.º 2
0
    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.

    bug.last_polled = datetime.datetime.utcnow()

    return bug

BUG_URL_PREFIX = 'http://bugs.opensolaris.org/bugdatabase/view_bug.do?bug_id='

def get_remote_bug_ids_to_read():
    remote_bug_list = 'http://hub.opensolaris.org/bin/view/Main/oss_bite_size'
    tree = lxml.html.document_fromstring(urllib2.urlopen(remote_bug_list).read())
    for a in tree.cssselect('a'):
        if BUG_URL_PREFIX in (
            a.attrib.get('href', '')):
            yield bug_url2bug_id(a.attrib['href'])