瀏覽代碼

First tests for imdb module

Colin Powell 2 年之前
父節點
當前提交
cbe4abfb5f
共有 3 個文件被更改,包括 16 次插入2 次删除
  1. 2 0
      .coveragerc
  2. 12 0
      tests/scrobbles_tests/test_imdb.py
  3. 2 2
      vrobbler/apps/scrobbles/imdb.py

+ 2 - 0
.coveragerc

@@ -3,3 +3,5 @@ omit=
   vrobbler/wsgi.py
   vrobbler/asgi.py
   vrobbler/cli.py
+  *admin.py
+  migrations/*

+ 12 - 0
tests/scrobbles_tests/test_imdb.py

@@ -0,0 +1,12 @@
+import pytest
+import imdb
+from mock import patch
+
+from vrobbler.apps.scrobbles.imdb import lookup_video_from_imdb
+
+
+def test_lookup_imdb_bad_id(caplog):
+    data = lookup_video_from_imdb('3409324')
+    assert data is None
+    assert caplog.records[0].levelname == "WARNING"
+    assert caplog.records[0].msg == "IMDB ID should begin with 'tt' 3409324"

+ 2 - 2
vrobbler/apps/scrobbles/imdb.py

@@ -2,10 +2,10 @@ import logging
 from typing import Optional
 from django.utils import timezone
 
-import imdb
+from imdb import Cinemagoer
 from videos.models import Video
 
-imdb_client = imdb.Cinemagoer()
+imdb_client = Cinemagoer()
 
 logger = logging.getLogger(__name__)