add _unique_name tests
Browse files- tests/test_cli.py +17 -0
tests/test_cli.py
CHANGED
@@ -377,3 +377,20 @@ def test_perform_args_on_youtube(youtube):
|
|
377 |
cli.main()
|
378 |
youtube.assert_called()
|
379 |
cli._perform_args_on_youtube.assert_called()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
377 |
cli.main()
|
378 |
youtube.assert_called()
|
379 |
cli._perform_args_on_youtube.assert_called()
|
380 |
+
|
381 |
+
|
382 |
+
@mock.patch("pytube.cli.os.path.exists", return_value=False)
|
383 |
+
def test_unique_name(path_exists):
|
384 |
+
assert (
|
385 |
+
cli._unique_name("base", "subtype", "video", "target")
|
386 |
+
== "target/base_video_0.subtype"
|
387 |
+
)
|
388 |
+
|
389 |
+
|
390 |
+
@mock.patch("pytube.cli.os.path.exists")
|
391 |
+
def test_unique_name_counter(path_exists):
|
392 |
+
path_exists.side_effect = [True, False]
|
393 |
+
assert (
|
394 |
+
cli._unique_name("base", "subtype", "video", "target")
|
395 |
+
== "target/base_video_1.subtype"
|
396 |
+
)
|