def test_get_date_from_iso_string_expected(self): d = date_util.get_date_from_iso_string( '2020-02-08T04:03:07.1786999+00:00') self.assertEqual(d.year, 2020) self.assertEqual(d.month, 2) self.assertEqual(d.day, 8) d = date_util.get_date_from_iso_string('2019-06-24T13:13:58.739069') self.assertEqual(d.year, 2019) self.assertEqual(d.month, 6) self.assertEqual(d.day, 24)
def __fetch_and_populate_version(self, registrationsIndex: RegistrationsIndex, package: Package): if registrationsIndex and package.version: for page in registrationsIndex.items: if not version_util.is_newer_release(page.upper, package.version): for leaf in page.items(): if leaf.catalogEntry.version == package.version and leaf.commitTimeStamp: package.version_date = date_util.get_date_from_iso_string(leaf.commitTimeStamp).strftime('%Y-%m-%d') return
def __fetch_and_populate_latest_version(self, registrationsIndex: RegistrationsIndex, package: Package): # current version metadata if registrationsIndex: # assuming the newest is aways at the end of the list for page in reversed(registrationsIndex.items): for leaf in reversed(page.items()): package.latest_version = leaf.catalogEntry.version if leaf.commitTimeStamp: package.latest_version_date = date_util.get_date_from_iso_string(leaf.commitTimeStamp).strftime('%Y-%m-%d') return
def test_get_date_from_iso_string_nothing(self): with self.assertRaises(AssertionError): date_util.get_date_from_iso_string('') with self.assertRaises(AssertionError): d = None date_util.get_date_from_iso_string(d)