def get_source_events(event_source_main): f = getmodule(event_source_main).__name__.split('.')[-1] try: events = event_source_main() if not BUCKET: n = len(events) print(f"Scraped {n} event(s) for {f}") except Exception as e: msg = f'Exception getting events in {f}: {e}' logger.critical(msg, exc_info=True) return [] events = [{k: formatters.unicoder(v) for k, v in i.items()} for i in events] for i, event in enumerate(events): try: schema_test([event]) except Exception as e: msg = f'Exception getting events in {f}: {e}' logger.error(msg, exc_info=True) events.pop(i) events = formatters.tag_events_with_state(events) events = formatters.date_filter(events) return events
def test_unicoder_accents(self): result = unicoder('áéíóúüñ¿¡') expected = 'áéíóúüñ¿¡' self.assertEqual(result, expected)
def test_unicoder_quotes(self): result = unicoder('“') expected = '“' self.assertEqual(result, expected)
def test_unicoder_empty(self): result = unicoder('Â') expected = "" self.assertEqual(result, expected)
def test_unicoder_dash(self): result = unicoder('Earth Day – Monday Mini Camp') expected = "Earth Day – Monday Mini Camp" self.assertEqual(result, expected)
def test_unicoder_apostrophe(self): result = unicoder('We’ll') expected = "We’ll" self.assertEqual(result, expected)
def test_unicoder(self): result = unicoder('test') expected = 'test' self.assertEqual(result, expected)