def setUp(self): dirname = os.path.dirname(os.path.realpath(__file__)) fixture = os.path.normpath(os.path.join(dirname, '../fixtures', self.filename)) provider = {'name': 'Test'} with open(fixture, 'rb') as f: parser = STTNewsMLFeedParser() self.xml_root = etree.parse(f).getroot() self.item = parser.parse(self.xml_root, provider)
def test_timestamps(self): item = self.item[0] self.assertEqual("2013-02-16T15:36:20+00:00", item["firstcreated"].isoformat()) self.assertEqual("2013-02-22T16:36:20+00:00", item["versioncreated"].isoformat()) self.assertEqual("2013-02-22T16:36:20+00:00", item["firstpublished"].isoformat()) self.assertIn({"qcode": "5", "scheme": "sttdone1", "name": ""}, item["subject"]) # test daylight savings self.assertEqual("2018-01-01T10:00:00+00:00", STTNewsMLFeedParser().datetime("2018-01-01T12:00:00").isoformat()) self.assertEqual("2018-08-01T09:00:00+00:00", STTNewsMLFeedParser().datetime("2018-08-01T12:00:00").isoformat())
def test_timestamps(self): item = self.item[0] self.assertEqual('2013-02-16T15:36:20+00:00', item['firstcreated'].isoformat()) self.assertEqual('2013-02-16T16:36:20+00:00', item['versioncreated'].isoformat()) self.assertEqual('2013-02-16T16:36:20+00:00', item['firstpublished'].isoformat()) self.assertIn({ 'qcode': '5', 'scheme': 'sttdone1', 'name': '' }, item['subject']) # test daylight savings self.assertEqual( '2018-01-01T10:00:00+00:00', STTNewsMLFeedParser().datetime('2018-01-01T12:00:00').isoformat()) self.assertEqual( '2018-08-01T09:00:00+00:00', STTNewsMLFeedParser().datetime('2018-08-01T12:00:00').isoformat())
def test_can_parse(self): self.assertTrue(STTNewsMLFeedParser().can_parse(self.xml_root))