import unittest from datetime import datetime, timedelta from dailyreleases import parsing from dailyreleases.parsing import Platform, ReleaseType from dailyreleases.predbs import PredbRelease class ParseReleasesTestCase(unittest.TestCase): @classmethod def setUpClass(cls) -> None: cls.empty_releases = {platform: {release_type: [] for release_type in ReleaseType} for platform in Platform} def test_dont_skip(self): already_posted = set() releases = [ PredbRelease("Aztez-DARKSiDERS", "nfo_link", datetime.now()) ] parsed_releases = parsing.parse_releases(releases, already_posted) self.assertEqual(parsed_releases[Platform.WINDOWS][ReleaseType.GAME][0].game_name, "Aztez") def test_skip_already_posted(self): already_posted = {"Aztez-DARKSiDERS"} releases = [ PredbRelease("Aztez-DARKSiDERS", "nfo_link", datetime.now()) ] parsed_releases = parsing.parse_releases(releases, already_posted) self.assertDictEqual(parsed_releases, self.empty_releases) def test_skip_blacklisted_word(self): already_posted = set() releases = [ PredbRelease("Anthemion.Software.DialogBlocks.v5.15.LINUX.Incl.Keygen-AMPED", "nfo_link", datetime.now()) ] parsed_releases = parsing.parse_releases(releases, already_posted) self.assertDictEqual(parsed_releases, self.empty_releases) def test_skip_older_than_48hr(self): already_posted = set() releases = [ PredbRelease("Aztez-DARKSiDERS", "nfo_link", datetime.now() - timedelta(hours=50)) ] parsed_releases = parsing.parse_releases(releases, already_posted) self.assertDictEqual(parsed_releases, self.empty_releases) def test_skip_no_data_for_software(self): already_posted = set() releases = [ PredbRelease("Tecplot.RS.2017.R1.v1.2.85254.X64-AMPED", "nfo_link", datetime.now()) ] parsed_releases = parsing.parse_releases(releases, already_posted) self.assertDictEqual(parsed_releases, self.empty_releases) if __name__ == '__main__': unittest.main()