Browse Source

Add tests for BGG

Colin Powell 1 year ago
parent
commit
7e16388f81
3 changed files with 35 additions and 5 deletions
  1. 27 0
      tests/boardgames_tests/test_bgg.py
  2. 4 4
      vrobbler.conf.test
  3. 4 1
      vrobbler/apps/boardgames/bgg.py

+ 27 - 0
tests/boardgames_tests/test_bgg.py

@@ -0,0 +1,27 @@
+from boardgames.bgg import (
+    take_first,
+    lookup_boardgame_id_from_bgg,
+    lookup_boardgame_from_bgg,
+)
+
+
+def test_take_first():
+    assert take_first([]) == ""
+
+    assert take_first(["a", "b"]) == "a"
+
+
+def test_lookup_boardgame_id_from_bgg():
+    bgg_id = lookup_boardgame_id_from_bgg("Cosmic Encounter")
+    assert bgg_id == "15"
+
+    bgg_id = lookup_boardgame_id_from_bgg("Comedy Encounter")
+    assert bgg_id == None
+
+
+def test_lookup_boardgame_from_bgg():
+    bgg_result = lookup_boardgame_from_bgg(15)
+    assert bgg_result.get("bggeek_id") == 15
+
+    bgg_result = lookup_boardgame_from_bgg("Cosmic Encounter")
+    assert bgg_result.get("bggeek_id") == "15"

+ 4 - 4
vrobbler.conf.test

@@ -1,11 +1,11 @@
 # Local configuration for Emus
 
-VROBBLER_DUMP_REQUEST_DATA=True
-VROBBLER_LOG_TO_CONSOLE=True
-VROBBLER_DEBUG=True
+VROBBLER_DUMP_REQUEST_DATA=False
+VROBBLER_LOG_TO_CONSOLE=False
+VROBBLER_DEBUG=False
 VROBBLER_LOG_LEVEL="DEBUG"
 VROBBLER_MEDIA_ROOT = "/tmp/media/"
-VROBBLER_KEEP_DETAILED_SCROBBLE_LOGS=True
+VROBBLER_KEEP_DETAILED_SCROBBLE_LOGS=False
 
 VROBBLER_USE_S3="False"
 VROBBLER_DATABASE_URL="sqlite:///testdb.sqlite3"

+ 4 - 1
vrobbler/apps/boardgames/bgg.py

@@ -20,7 +20,10 @@ def take_first(thing: Optional[list]) -> str:
         pass
 
     if first:
-        first = first.get_text()
+        try:
+            first = first.get_text()
+        except:
+            pass
 
     return first