def test_invalid(self, element, tree): element.append(ATOME('published', 'garbage')) logger = RecordingLogger() entry = self.parse(tree, wrap_recording_logger(logger)) assert entry.published is None assert logger.messages == [{ 'event': 'invalid-published', 'cause': 'invalid-date', 'date': 'garbage', 'source': None, 'lineno': None }]
def test_invalid(self, qname, element, tree): element.remove(element.find(qname)) element.append(ATOME('updated', 'garbage')) logger = RecordingLogger() feed = atomrss.atom.parse_tree(tree, wrap_recording_logger(logger)) assert feed.entries == [] assert logger.messages == [{ 'event': 'invalid-entry', 'cause': 'invalid-date', 'date': 'garbage', 'lineno': None, 'source': None }]
def test_invalid_length(self, element, enclosure_element, tree): enclosure_element.attrib['length'] = 'garbage' element.append(enclosure_element) logger = RecordingLogger() item = self.parse(tree, logger=wrap_recording_logger(logger)) assert item.enclosure is None assert logger.messages == [{ 'event': 'invalid-enclosure', 'cause': 'invalid-length', 'length': 'garbage', 'rss_version': '2.0', 'lineno': None, 'source': None }]
def test_missing_type(self, element, enclosure_element, tree): del enclosure_element.attrib['type'] element.append(enclosure_element) logger = RecordingLogger() item = self.parse(tree, logger=wrap_recording_logger(logger)) assert item.enclosure is None assert logger.messages == [{ 'event': 'invalid-enclosure', 'cause': 'missing-attribute', 'attribute': 'type', 'rss_version': '2.0', 'lineno': None, 'source': None }]
def test_missing(self, element, tree): element.remove(element.find('title')) assert element.find('description') is None logger = RecordingLogger() feed = atomrss.rss.parse_tree(tree, wrap_recording_logger(logger)) assert feed.channel.items == [] assert logger.messages == [{ 'event': 'invalid-item', 'cause': 'missing-element', 'element': '<title> or <description>', 'rss_version': '2.0', 'source': None, 'lineno': None }]
def test_missing(self, qname, element, tree): element.remove(element.find(qname)) logger = RecordingLogger() feed = atomrss.atom.parse_tree(tree, wrap_recording_logger(logger)) assert feed.entries == [] assert logger.messages == [{ 'event': 'invalid-entry', 'cause': 'missing-element', 'element': '<atom:{}>'.format(self.element_name), 'source': None, 'lineno': None }]