Beispiel #1
0
 def testImportBad(self):
     data1 = file(testdata_filename).read()
     data2 = data1.replace('<review id="17542">', '<somethingelse>')
     data2 = data2.replace('</review>', '</somethingelse>', 1)
     data1 = sehepunkte_parser.parse(data1)
     data2 = sehepunkte_parser.parse(data2)
     # Two because I am lazy. The first result contains two books that results in two results
     # the replace above can only break the first import.
     self.assertEquals(len(list(data1)), len(list(data2)) + 2)
    def __call__(self):
        data = []
        before = datetime.datetime.now()
        review_count = 0
        for url in self._getTargetURLs():
            try:
                data.append(sehepunkte_parser.parse(urllib.urlopen(url).read()))
            except IOError:
                pass # The library takes care of logging a failure
        for review in chain(*data):
            try:
                self._addReview(self._convertVocabulary(\
                                 convertToString(\
                                  review)))
                review_count += 1
            except:
                log.exception("Warning, sehepunkte import failed! Exception "
                    "has not been catched, but bubbled. Probably sehepunkte "
                    "is broken now! Please see #4656 for fixes")
                raise

        total = (datetime.datetime.now() - before).seconds / 1.0
        log.info("Sehepunkte finished. Imported %i reviews "
            "in %f seconds. %f reviews/s",
            review_count, total, total and review_count / total or review_count)
        return "Success"
Beispiel #3
0
 def testImportGood(self):
     data = [x for x in sehepunkte_parser.parse(
             file(testdata_filename).read())]
     self.maxDiff = None
     self.assertEquals(testdata_parsed, list(data))