2018-07-31 17:34:45 +02:00
|
|
|
import unittest
|
2019-03-15 01:24:26 +01:00
|
|
|
from datetime import datetime, timedelta
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2019-03-08 02:38:55 +01:00
|
|
|
from dailyreleases import parsing
|
2019-03-15 01:24:26 +01:00
|
|
|
from dailyreleases.parsing import ReleaseType, Platform, ParseError
|
|
|
|
from dailyreleases.predbs import Pre
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ParseDirnameTestCase(unittest.TestCase):
|
|
|
|
def test_single_word_release(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Aztez-DARKSiDERS", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
|
|
|
|
self.assertEqual("Aztez-DARKSiDERS", r.dirname)
|
|
|
|
self.assertEqual("Aztez", r.rls_name)
|
|
|
|
self.assertEqual("Aztez", r.game_name)
|
|
|
|
self.assertEqual(Platform.WINDOWS, r.platform)
|
|
|
|
self.assertEqual(ReleaseType.GAME, r.type)
|
|
|
|
self.assertEqual("DARKSiDERS", r.group)
|
|
|
|
self.assertIn("store.steampowered.com/app/244750", r.store_links["Steam"])
|
|
|
|
self.assertEqual([], r.tags)
|
|
|
|
self.assertEqual([], r.highlights)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2019-03-15 01:24:26 +01:00
|
|
|
def test_error_on_blacklisted_word(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Anthemion.Software.DialogBlocks.v5.15.LINUX.Incl.Keygen-AMPED",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-03-15 01:24:26 +01:00
|
|
|
with self.assertRaisesRegex(ParseError, "Contains blacklisted word"):
|
|
|
|
parsing.parse_pre(pre)
|
|
|
|
|
|
|
|
def test_error_on_old(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Aztez-DARKSiDERS", "nfo_link", datetime.utcnow() - timedelta(hours=50)
|
|
|
|
)
|
2019-03-15 01:24:26 +01:00
|
|
|
with self.assertRaisesRegex(ParseError, "Older than 48 hours"):
|
|
|
|
parsing.parse_pre(pre)
|
|
|
|
|
|
|
|
def test_error_on_software(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Tecplot.RS.2017.R1.v1.2.85254.X64-AMPED", "nfo_link", datetime.utcnow()
|
|
|
|
)
|
2019-03-15 01:24:26 +01:00
|
|
|
with self.assertRaisesRegex(ParseError, "No store link: probably software"):
|
|
|
|
parsing.parse_pre(pre)
|
|
|
|
|
2018-07-31 17:34:45 +02:00
|
|
|
def test_nuked_release(self):
|
|
|
|
# TODO: Actual nuke handling?
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Battlefield.1-CPY", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual("Battlefield.1-CPY", r.dirname)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_update(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Car.Mechanic.Simulator.2018.Plymouth.Update.v1.5.1.Hotfix-PLAZA",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(ReleaseType.UPDATE, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/app/754920", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_proper_highlight(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Death.Coming.PROPER-SiMPLEX", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(["PROPER"], r.highlights)
|
|
|
|
self.assertIn("store.steampowered.com/app/705120", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_macos_release(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"The_Fall_Part_2_Unbound_MacOS-Razor1911", "nfo_link", datetime.utcnow()
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(Platform.OSX, r.platform)
|
|
|
|
self.assertEqual(ReleaseType.GAME, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/app/510490", r.store_links["Steam"])
|
2023-02-11 01:15:58 +01:00
|
|
|
self.assertIn("gog.com/en/game/the_fall_part_2_unbound", r.store_links["GOG"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_macosx_update(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
2023-02-11 01:15:58 +01:00
|
|
|
"Cult_of_the_Lamb_v1.1.3_MacOS-Razor1911",
|
2022-06-12 18:45:25 +02:00
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(Platform.OSX, r.platform)
|
|
|
|
self.assertEqual(ReleaseType.UPDATE, r.type)
|
2023-02-11 01:15:58 +01:00
|
|
|
self.assertIn("store.steampowered.com/app/1313140", r.store_links["Steam"])
|
|
|
|
self.assertIn("gog.com/en/game/cult_of_the_lamb", r.store_links["GOG"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_linux_release(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Sphinx_And_The_Cursed_Mummy_Linux-Razor1911", "nfo_link", datetime.utcnow()
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(Platform.LINUX, r.platform)
|
|
|
|
self.assertEqual(ReleaseType.GAME, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/app/606710", r.store_links["Steam"])
|
2023-02-11 01:15:58 +01:00
|
|
|
self.assertIn("gog.com/en/game/sphinx_and_the_cursed_mummy", r.store_links["GOG"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_dlc_explicit(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Fallout.4.Far.Harbor.DLC-CODEX", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertIn("store.steampowered.com/app/435881", r.store_links["Steam"])
|
|
|
|
self.assertEqual(ReleaseType.DLC, r.type)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_dlc_implicit(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Euro.Truck.Simulator.2.Italia-CODEX", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(ReleaseType.DLC, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/app/558244", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_incl_dlc_update(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Wolfenstein.II.The.New.Colossus.Update.5.incl.DLC-CODEX",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(ReleaseType.UPDATE, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/app/612880", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_incl_dlc_release(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Mutiny.Incl.DLC-DARKSiDERS", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(ReleaseType.GAME, r.type)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2018-08-03 03:30:17 +02:00
|
|
|
def test_score_steam(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("BioShock_Infinite-FLT", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r1 = parsing.parse_pre(pre)
|
|
|
|
self.assertIn("store.steampowered.com/app/8870", r1.store_links["Steam"])
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Duke.Nukem.Forever.Complete-PLAZA", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r2 = parsing.parse_pre(pre)
|
|
|
|
self.assertIn("store.steampowered.com/app/57900", r2.store_links["Steam"])
|
|
|
|
self.assertGreater(r1.score, r2.score)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2023-02-11 01:15:10 +01:00
|
|
|
def test_ea(self):
|
|
|
|
pre = Pre("Madden.NFL.21.REPACK-CPY", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
2022-06-12 18:45:25 +02:00
|
|
|
self.assertIn(
|
2023-02-11 01:15:10 +01:00
|
|
|
"ea.com/games/madden-nfl/madden-nfl-23",
|
|
|
|
r.store_links["EA"],
|
2022-06-12 18:45:25 +02:00
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
self.assertEqual(-1, r.score)
|
|
|
|
self.assertEqual(-1, r.num_reviews)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_gog_exclusive(self):
|
2023-02-11 01:15:58 +01:00
|
|
|
# https://www.gog.com/en/games?tags=only-on-gog
|
2019-03-08 02:38:55 +01:00
|
|
|
# TODO: Actually use GOG API (gog.update_info)
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
2023-02-11 01:15:58 +01:00
|
|
|
"SimCity.3000.Unlimited.v2.0.0.10.Multilingual-DELiGHT",
|
2022-06-12 18:45:25 +02:00
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
2023-02-11 01:15:58 +01:00
|
|
|
self.assertIn("www.gog.com/en/game/simcity_3000", r.store_links["GOG"])
|
2019-05-12 21:02:01 +02:00
|
|
|
self.assertEqual(-1, r.score)
|
2019-03-08 02:38:55 +01:00
|
|
|
|
|
|
|
def test_gog_exclusive2(self):
|
2023-02-11 01:15:58 +01:00
|
|
|
pre = Pre("Europa.Universalis.II-KaliMaaShaktiDe", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
2023-02-11 01:15:58 +01:00
|
|
|
self.assertIn("gog.com/en/game/europa_universalis_ii", r.store_links["GOG"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2019-06-07 21:17:28 +02:00
|
|
|
def test_epic_games_exclusive(self):
|
2022-07-10 16:12:01 +02:00
|
|
|
pre = Pre("Vampire_The_Masquerade_Swansong-Razor1911", "nfo_link", datetime.utcnow())
|
2019-06-07 21:17:28 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
2022-06-12 18:45:25 +02:00
|
|
|
self.assertIn(
|
2022-07-10 16:12:01 +02:00
|
|
|
"store.epicgames.com/en-US/p/vampire-the-masquerade-swansong", r.store_links["Epic Games"]
|
2022-06-12 18:45:25 +02:00
|
|
|
)
|
2019-06-07 21:17:28 +02:00
|
|
|
|
2018-08-03 03:30:17 +02:00
|
|
|
def test_score_non_steam(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Ode.RIP.MULTI12-SiMPLEX", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(-1, r.score)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_tags(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"The.Curious.Expedition.v1.3.7.1.MULTI.7.RIP-Unleashed",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
2023-02-11 01:15:58 +01:00
|
|
|
self.assertIn("store.steampowered.com/app/358130", r.store_links["Steam"])
|
2019-05-12 21:02:01 +02:00
|
|
|
self.assertEqual(["MULTI.7", "RIP"], r.tags)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_steam_package(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Anno.2070.Complete.Edition-FAKE", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual("Anno 2070 Complete Edition", r.game_name)
|
2022-06-12 18:45:25 +02:00
|
|
|
self.assertGreaterEqual(
|
|
|
|
r.num_reviews, 9354
|
|
|
|
) # make sure we got the right game from the package
|
2019-05-12 21:02:01 +02:00
|
|
|
self.assertIn("store.steampowered.com/sub/26683", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_steam_package_with_dlc_first(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"The.Witcher.3.Wild.Hunt.Game.of.The.Year.Edition-RELOADED",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
2022-06-12 18:45:25 +02:00
|
|
|
self.assertEqual(
|
|
|
|
"The Witcher 3: Wild Hunt - Game of the Year Edition", r.game_name
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
self.assertEqual(ReleaseType.GAME, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/sub/124923", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_steam_bundle(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Valve.Complete.Pack-FAKE", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual("Valve.Complete.Pack-FAKE", r.dirname)
|
|
|
|
self.assertEqual("Valve Complete Pack", r.game_name)
|
|
|
|
self.assertEqual("Windows", r.platform)
|
|
|
|
self.assertEqual(ReleaseType.GAME, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/bundle/232", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2019-03-23 22:42:26 +01:00
|
|
|
def test_denuvo_in_steam_eula(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Deus.Ex.Mankind.Divided-CPY", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(["DENUVO"], r.highlights)
|
2018-08-04 19:37:19 +02:00
|
|
|
|
2019-03-23 22:42:26 +01:00
|
|
|
def test_denuvo_in_steam_drm_notice(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Batman.Arkham.Knight-CPY", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(["DENUVO"], r.highlights)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_episode_release(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Life.is.Strange.Before.the.Storm.Episode.3-CODEX",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual("Life is Strange: Before the Storm Episode 3", r.game_name)
|
|
|
|
self.assertEqual(ReleaseType.DLC, r.type)
|
|
|
|
self.assertIn("store.steampowered.com/app/704740", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_season_and_episode_release(self):
|
2022-06-12 18:45:25 +02:00
|
|
|
pre = Pre(
|
|
|
|
"Minecraft.Story.Mode.Season.Two.Episode.5.MacOSX-RELOADED",
|
|
|
|
"nfo_link",
|
|
|
|
datetime.utcnow(),
|
|
|
|
)
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual("Minecraft Story Mode Season Two Episode 5", r.game_name)
|
2018-07-31 17:34:45 +02:00
|
|
|
|
|
|
|
def test_build_is_update(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("DUSK.Episode.1.Build.2.6-SKIDROW", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertEqual(ReleaseType.UPDATE, r.type)
|
2019-03-08 02:38:55 +01:00
|
|
|
|
|
|
|
def test_prefer_steam_to_microsoft_store(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Forgiveness-PLAZA", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre)
|
|
|
|
self.assertIn("store.steampowered.com/app/971120", r.store_links["Steam"])
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2019-03-23 22:42:26 +01:00
|
|
|
def test_abbreviated_name(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("R.O.V.E.R.The.Game-HOODLUM", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre, offline=True)
|
|
|
|
self.assertEqual("R.O.V.E.R The Game", r.game_name)
|
2019-03-23 22:42:26 +01:00
|
|
|
|
|
|
|
def test_abbreviated_name_splits_single_letter(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("Tick.Tock.A.Tale.for.Two-DARKSiDERS", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre, offline=True)
|
|
|
|
self.assertEqual("Tick Tock A Tale for Two", r.game_name)
|
2019-03-23 22:42:26 +01:00
|
|
|
|
|
|
|
def test_abbreviated_name_splits_single_number(self):
|
2019-05-12 03:25:30 +02:00
|
|
|
pre = Pre("GTA.5.The.Complete.Edition-TEST", "nfo_link", datetime.utcnow())
|
2019-05-12 21:02:01 +02:00
|
|
|
r = parsing.parse_pre(pre, offline=True)
|
|
|
|
self.assertEqual("GTA 5 The Complete Edition", r.game_name)
|
2019-03-23 22:42:26 +01:00
|
|
|
|
2018-07-31 17:34:45 +02:00
|
|
|
|
2022-06-12 18:45:25 +02:00
|
|
|
if __name__ == "__main__":
|
2018-07-31 17:34:45 +02:00
|
|
|
unittest.main()
|