1
0
Fork 0
This repository has been archived on 2023-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
dailyreleases/tests/test_parse_releases.py
Casper V. Kristensen 4023b095a4
Version 0.0.3.
Change design from OOP to more of a "modules" approach.
Remove dependency on "requests" and "requests_cache".
Implement custom cache wrapper for urllib.
Increase code cohesion.
Update and add further tests.
2019-03-08 02:38:55 +01:00

59 lines
2.2 KiB
Python

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()