This commit is contained in:
1 parent
b865a4a389
commit
d07dec5e75
19 files changed
+258
-23
No files matched your search
@@ -0,0 +1,33 @@
|
||||
"""Tests for the optional HLTB enrichment helpers."""
|
||||
|
||||
import os
|
||||
import sys
|
||||
import unittest
|
||||
from types import SimpleNamespace
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
sys.path.insert(0, os.path.join(ROOT, "tools"))
|
||||
|
||||
import fetch_hltb
|
||||
|
||||
|
||||
class HltbTests(unittest.TestCase):
|
||||
def test_normalize(self):
|
||||
self.assertEqual(fetch_hltb.normalize("Hades™ (R)"), "hades")
|
||||
self.assertEqual(fetch_hltb.normalize("Half-Life 2"), "half life 2")
|
||||
self.assertEqual(fetch_hltb.normalize(""), "")
|
||||
|
||||
def test_find_exact_match_only(self):
|
||||
entries = [SimpleNamespace(game_name="Hades"), SimpleNamespace(game_name="Hades II")]
|
||||
self.assertEqual(fetch_hltb.find_match(entries, "hades").game_name, "Hades")
|
||||
self.assertIsNone(fetch_hltb.find_match(entries, "Hade"))
|
||||
|
||||
def test_positive(self):
|
||||
self.assertEqual(fetch_hltb.positive("23.5"), 23.5)
|
||||
self.assertIsNone(fetch_hltb.positive(0))
|
||||
self.assertIsNone(fetch_hltb.positive("n/a"))
|
||||
self.assertIsNone(fetch_hltb.positive(None))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
Reference in new issue
Block a user