diff --git a/tests/boardgames_tests/test_bgg.py b/tests/boardgames_tests/test_bgg.py new file mode 100644 index 0000000..ce590ce --- /dev/null +++ b/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" diff --git a/vrobbler.conf.test b/vrobbler.conf.test index 9541b3a..2aac214 100644 --- a/vrobbler.conf.test +++ b/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" diff --git a/vrobbler/apps/boardgames/bgg.py b/vrobbler/apps/boardgames/bgg.py index a69ac02..897f5ae 100644 --- a/vrobbler/apps/boardgames/bgg.py +++ b/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