import unittest from dailyreleases import parsing from dailyreleases.parsing import ReleaseType, Platform class ParseDirnameTestCase(unittest.TestCase): def test_single_word_release(self): p = parsing.parse_dirname("Aztez-DARKSiDERS", "nfo_link") self.assertEqual("Aztez-DARKSiDERS", p.dirname) self.assertEqual("Aztez", p.rls_name) self.assertEqual("Aztez", p.game_name) self.assertEqual(Platform.WINDOWS, p.platform) self.assertEqual(ReleaseType.GAME, p.type) self.assertEqual("DARKSiDERS", p.group) self.assertIn("store.steampowered.com/app/244750", p.store_links["Steam"]) self.assertEqual([], p.tags) self.assertEqual([], p.highlights) def test_nuked_release(self): # TODO: Actual nuke handling? p = parsing.parse_dirname("Battlefield.1-CPY", "nfo_link") self.assertEqual("Battlefield.1-CPY", p.dirname) def test_update(self): p = parsing.parse_dirname("Car.Mechanic.Simulator.2018.Plymouth.Update.v1.5.1.Hotfix-PLAZA", "nfo_link") self.assertEqual(ReleaseType.UPDATE, p.type) self.assertIn("store.steampowered.com/app/754920", p.store_links["Steam"]) def test_proper_highlight(self): p = parsing.parse_dirname("Death.Coming.PROPER-SiMPLEX", "nfo_link") self.assertEqual(["PROPER"], p.highlights) self.assertIn("store.steampowered.com/app/705120", p.store_links["Steam"]) def test_macos_release(self): p = parsing.parse_dirname("The_Fall_Part_2_Unbound_MacOS-Razor1911", "nfo_link") self.assertEqual(Platform.OSX, p.platform) self.assertEqual(ReleaseType.GAME, p.type) self.assertIn("store.steampowered.com/app/510490", p.store_links["Steam"]) self.assertIn("gog.com/game/the_fall_part_2_unbound", p.store_links["GOG"]) def test_macosx_update(self): p = parsing.parse_dirname("Man_O_War_Corsair_Warhammer_Naval_Battles_v1.3.2_MacOSX-Razor1911", "nfo_link") self.assertEqual(Platform.OSX, p.platform) self.assertEqual(ReleaseType.UPDATE, p.type) self.assertIn("store.steampowered.com/app/344240", p.store_links["Steam"]) self.assertIn("gog.com/game/man_o_war_corsair", p.store_links["GOG"]) def test_linux_release(self): p = parsing.parse_dirname("Sphinx_And_The_Cursed_Mummy_Linux-Razor1911", "nfo_link") self.assertEqual(Platform.LINUX, p.platform) self.assertEqual(ReleaseType.GAME, p.type) self.assertIn("store.steampowered.com/app/606710", p.store_links["Steam"]) self.assertIn("gog.com/game/sphinx_and_the_cursed_mummy", p.store_links["GOG"]) def test_dlc_explicit(self): p = parsing.parse_dirname("Fallout.4.Far.Harbor.DLC-CODEX", "nfo_link") self.assertIn("store.steampowered.com/app/435881", p.store_links["Steam"]) self.assertEqual(ReleaseType.DLC, p.type) def test_dlc_implicit(self): p = parsing.parse_dirname("Euro.Truck.Simulator.2.Italia-CODEX", "nfo_link") self.assertEqual(ReleaseType.DLC, p.type) self.assertIn("store.steampowered.com/app/558244", p.store_links["Steam"]) def test_incl_dlc_update(self): p = parsing.parse_dirname("Wolfenstein.II.The.New.Colossus.Update.5.incl.DLC-CODEX", "nfo_link") self.assertEqual(ReleaseType.UPDATE, p.type) self.assertIn("store.steampowered.com/app/612880", p.store_links["Steam"]) def test_incl_dlc_release(self): p = parsing.parse_dirname("Mutiny.Incl.DLC-DARKSiDERS", "nfo_link") self.assertEqual(ReleaseType.GAME, p.type) def test_score_steam(self): p1 = parsing.parse_dirname("BioShock_Infinite-FLT", "nfo_link") self.assertIn("store.steampowered.com/app/8870", p1.store_links["Steam"]) p2 = parsing.parse_dirname("Duke.Nukem.Forever.Complete-PLAZA", "nfo_link") self.assertIn("store.steampowered.com/app/57900", p2.store_links["Steam"]) self.assertGreater(p1.score, p2.score) def test_non_steam(self): p = parsing.parse_dirname("Battlefield.1.REPACK-CPY", "nfo_link") self.assertIn("www.origin.com/usa/en-us/store/battlefield/battlefield-1", p.store_links["Origin"]) self.assertEqual(-1, p.score) self.assertEqual(-1, p.num_reviews) def test_gog_exclusive(self): # TODO: Actually use GOG API (gog.update_info) p = parsing.parse_dirname("Dungeons.and.Dragons.Dragonshard.v2.0.0.10.Multilingual-DELiGHT", "nfo_link") self.assertIn("gog.com/game/dungeons_dragons_dragonshard", p.store_links["GOG"]) self.assertEqual(-1, p.score) def test_gog_exclusive2(self): p = parsing.parse_dirname("Diablo.GOG.Classic-KaliMaaShaktiDe", "nfo_link") self.assertIn("gog.com/game/diablo", p.store_links["GOG"]) def test_score_non_steam(self): p = parsing.parse_dirname("Ode.RIP.MULTI12-SiMPLEX", "nfo_link") self.assertEqual(-1, p.score) def test_tags(self): p = parsing.parse_dirname("The.Curious.Expedition.v1.3.7.1.MULTI.7.RIP-Unleashed", "nfo_link") self.assertIn("gog.com/game/curious_expedition_the", p.store_links["GOG"]) self.assertEqual(["MULTI.7", "RIP"], p.tags) def test_skip_software(self): p = parsing.parse_dirname("Tecplot.RS.2017.R1.v1.2.85254.X64-AMPED", "nfo_link") self.assertIsNone(p) def test_steam_package(self): p = parsing.parse_dirname("Farming.Simulator.17.Platinum.Edition.Update.v1.5.3-BAT", "nfo_link") self.assertEqual("Farming Simulator 17 - Platinum Edition", p.game_name) self.assertEqual(ReleaseType.UPDATE, p.type) self.assertIn("store.steampowered.com/sub/202103", p.store_links["Steam"]) def test_steam_package_with_dlc_first(self): p = parsing.parse_dirname("The.Witcher.3.Wild.Hunt.Game.of.The.Year.Edition-RELOADED", "nfo_link") self.assertEqual("The Witcher 3: Wild Hunt - Game of the Year Edition", p.game_name) self.assertEqual(ReleaseType.GAME, p.type) self.assertIn("store.steampowered.com/sub/124923", p.store_links["Steam"]) def test_steam_bundle(self): p = parsing.parse_dirname("Valve.Complete.Pack-FAKE", "nfo_link") self.assertEqual("Valve.Complete.Pack-FAKE", p.dirname) self.assertEqual("Valve Complete Pack", p.game_name) self.assertEqual("Windows", p.platform) self.assertEqual(ReleaseType.GAME, p.type) self.assertIn("store.steampowered.com/bundle/232", p.store_links["Steam"]) def test_steam_denuvo(self): # "denuvo" occurs in the Steam EULA p = parsing.parse_dirname("Deus.Ex.Mankind.Divided-CPY", "nfo_link") self.assertEqual(["DENUVO"], p.highlights) # "denuvo" occurs in the Steam DRM notice p = parsing.parse_dirname("Yakuza.0-FAKE", "nfo_link") self.assertEqual(["DENUVO"], p.highlights) def test_episode_release(self): p = parsing.parse_dirname("Life.is.Strange.Before.the.Storm.Episode.3-CODEX", "nfo_link") self.assertEqual("Life is Strange: Before the Storm Episode 3", p.game_name) self.assertEqual(ReleaseType.DLC, p.type) self.assertIn("store.steampowered.com/app/704740", p.store_links["Steam"]) def test_season_and_episode_release(self): p = parsing.parse_dirname("Minecraft.Story.Mode.Season.Two.Episode.5.MacOSX-RELOADED", "nfo_link") self.assertEqual("Minecraft Story Mode Season Two Episode 5", p.game_name) def test_build_is_update(self): p = parsing.parse_dirname("DUSK.Episode.1.Build.2.6-SKIDROW", "nfo_link") self.assertEqual(ReleaseType.UPDATE, p.type) def test_prefer_steam_to_microsoft_store(self): p = parsing.parse_dirname("Forgiveness-PLAZA", "nfo_link") self.assertIn("store.steampowered.com/app/971120", p.store_links["Steam"]) if __name__ == '__main__': unittest.main()