Skip to content

Commit f31701c

Browse files
committed
minor cleanup
1 parent 6823682 commit f31701c

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

tests/test_omdb.py

+12-14
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
load_dotenv()
1616

17-
BUILD_TEST_DATA = True
17+
BUILD_TEST_DATA = False
1818
API_KEY = "superscret" if not BUILD_TEST_DATA else os.getenv("OMDB_API_KEY", "supersecret")
1919
RECORD_MODE = "new_episodes" if BUILD_TEST_DATA else "none"
2020

@@ -32,28 +32,26 @@ def __init__(self, api_key, timeout=5, strict=True):
3232
)
3333

3434
def _build_path(self, kwargs):
35+
if "s" in kwargs:
36+
if "type" in kwargs and kwargs["type"] == "series":
37+
return f"search/series/{kwargs['s']}"
38+
if "type" in kwargs and kwargs["type"] == "movie":
39+
return f"search/movie/{kwargs['s']}"
40+
return f"search/{kwargs['s']}"
41+
42+
val = kwargs["t"] if "t" in kwargs else kwargs["i"]
3543
if kwargs["apikey"] == "123456":
36-
val = kwargs["t"] if "t" in kwargs else kwargs["i"]
3744
return f"exceptions/bad_api_key/{val}"
3845
if "t" in kwargs and kwargs["t"] == "Random Movie Title":
39-
val = kwargs["t"] if "t" in kwargs else kwargs["i"]
4046
return f"exceptions/no_results/{val}"
4147
if "type" in kwargs and kwargs["type"] == "series":
42-
if "s" in kwargs: # searching for series
43-
return f"search/series/{kwargs['s']}"
44-
return f"series/{kwargs['t']}"
48+
return f"series/{val}"
4549
if "type" in kwargs and kwargs["type"] == "movie":
46-
if "s" in kwargs: # searching for series
47-
return f"search/movie/{kwargs['s']}"
48-
val = kwargs["t"] if "t" in kwargs else kwargs["i"]
4950
return f"movie/{val}"
5051
if "type" in kwargs and kwargs["type"] == "episode":
5152
if "Episode" in kwargs:
52-
return f"episode/{kwargs['t']}/episode-{kwargs['Episode']}"
53-
return f"episodes/{kwargs['t']}"
54-
if "s" in kwargs:
55-
return f"search/{kwargs['s']}"
56-
# print(kwargs)
53+
return f"episode/{val}/episode-{kwargs['Episode']}"
54+
return f"episodes/{val}"
5755

5856
return str(kwargs)
5957

0 commit comments

Comments
 (0)