songbirdcli 0.2.2__tar.gz → 0.2.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/PKG-INFO +1 -1
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/pyproject.toml +1 -1
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli/cli.py +1 -1
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli/helpers.py +4 -2
- songbirdcli-0.2.3/songbirdcli/version.py +1 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli.egg-info/PKG-INFO +1 -1
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli.egg-info/SOURCES.txt +2 -1
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/tests/unit/test_cli.py +11 -0
- songbirdcli-0.2.3/tests/unit/test_helpers.py +103 -0
- songbirdcli-0.2.2/songbirdcli/version.py +0 -1
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.dockerignore +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.github/workflows/docker.yml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.github/workflows/pages.yaml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.github/workflows/pypi-publish.yaml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.github/workflows/style.yml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.github/workflows/tests.yaml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/.gitignore +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/Dockerfile +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/LICENSE +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/Makefile +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/README.md +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/docs/index.md +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/docs/songbirdcli/cli.md +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/docs/songbirdcli/helpers.md +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/docs/songbirdcli/settings.md +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/markdownlint.yaml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/mkdocs.yml +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/setup.cfg +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli/requirements.txt +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli/requirements.txt.blank +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli/settings.py +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli.egg-info/dependency_links.txt +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli.egg-info/requires.txt +0 -0
- {songbirdcli-0.2.2 → songbirdcli-0.2.3}/songbirdcli.egg-info/top_level.txt +0 -0
|
@@ -388,7 +388,7 @@ def run(config: settings.SongbirdCliConfig):
|
|
|
388
388
|
current_mode = mode
|
|
389
389
|
continue
|
|
390
390
|
|
|
391
|
-
album_song_properties = launch_album_mode(album_name)
|
|
391
|
+
album_song_properties = helpers.launch_album_mode(album_name)
|
|
392
392
|
if album_song_properties is None:
|
|
393
393
|
break
|
|
394
394
|
|
|
@@ -142,6 +142,8 @@ def get_input(
|
|
|
142
142
|
if inp == quit_str:
|
|
143
143
|
return None
|
|
144
144
|
|
|
145
|
+
# initialize type to be empty by default
|
|
146
|
+
typed = None
|
|
145
147
|
if out_type is not None:
|
|
146
148
|
try:
|
|
147
149
|
typed = out_type(inp)
|
|
@@ -183,8 +185,8 @@ def get_input_list(prompt: str, sep: str, out_type=int, quit_str="q") -> List[in
|
|
|
183
185
|
|
|
184
186
|
str_list = inp.split(sep)
|
|
185
187
|
typed_list = []
|
|
186
|
-
# by default
|
|
187
|
-
type_check_passed =
|
|
188
|
+
# by default fail type check
|
|
189
|
+
type_check_passed = False
|
|
188
190
|
for item in str_list:
|
|
189
191
|
type_check_passed = True
|
|
190
192
|
try:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
version = "0.2.3"
|
|
@@ -29,6 +29,17 @@ cli_inputs = [
|
|
|
29
29
|
"l", # user selects save locally
|
|
30
30
|
"q", # user quits
|
|
31
31
|
],
|
|
32
|
+
[
|
|
33
|
+
"john mayer", # user enters john mayer
|
|
34
|
+
"", # user hits enter by accident
|
|
35
|
+
"0", # user continues by selecting property 0
|
|
36
|
+
"", # user opts to search youtube
|
|
37
|
+
"", # user hits enter by accident
|
|
38
|
+
"800", # user enters invalid input
|
|
39
|
+
"0", # user selects first song
|
|
40
|
+
"l", # user selects save locally
|
|
41
|
+
"q", # user quits
|
|
42
|
+
],
|
|
32
43
|
]
|
|
33
44
|
|
|
34
45
|
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import pytest
|
|
2
|
+
from typing import List, Optional
|
|
3
|
+
from songbirdcli import helpers
|
|
4
|
+
from songbirdcore.models import modes
|
|
5
|
+
from songbirdcore import itunes
|
|
6
|
+
|
|
7
|
+
@pytest.fixture()
|
|
8
|
+
def parse_itunes_search_api(monkeypatch):
|
|
9
|
+
return itunes.query_api(
|
|
10
|
+
"jolene",
|
|
11
|
+
mode=modes.Modes.SONG,
|
|
12
|
+
limit=10
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
@pytest.mark.parametrize(
|
|
16
|
+
"query,input_sequence",
|
|
17
|
+
(
|
|
18
|
+
# get billy joel the stranger, and remove the first three songs
|
|
19
|
+
("the stranger billy joel", ["0", "1 2 3"]),
|
|
20
|
+
# same as above, but specify no selection
|
|
21
|
+
("the stranger billy joel", ["0", "-1"]),
|
|
22
|
+
# same as above, but quit
|
|
23
|
+
("the stranger billy joel", ["0", "q"])
|
|
24
|
+
)
|
|
25
|
+
)
|
|
26
|
+
def test_launch_album_mode(monkeypatch, query, input_sequence):
|
|
27
|
+
monkeypatch.setattr("builtins.input", lambda _: next(iter(input_sequence)))
|
|
28
|
+
result = helpers.launch_album_mode(artist_album_string=query)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
@pytest.mark.parametrize(
|
|
32
|
+
"inp,out_type,choices,expected",
|
|
33
|
+
[
|
|
34
|
+
# ok with number casting to string
|
|
35
|
+
(0, str, None, "0"),
|
|
36
|
+
("q", str, ["y", "n"], None),
|
|
37
|
+
("y", str, ["y", "n"], "y"),
|
|
38
|
+
("", str, None, ""),
|
|
39
|
+
(0, int, [0, 1], 0),
|
|
40
|
+
(2, int, None, 2),
|
|
41
|
+
("q", int, None, None),
|
|
42
|
+
],
|
|
43
|
+
)
|
|
44
|
+
def test_get_input(monkeypatch, inp, out_type, choices, expected):
|
|
45
|
+
"""test get_input() function"""
|
|
46
|
+
# simulate user entering invalid inputs, and then one of the choices
|
|
47
|
+
monkeypatch.setattr("builtins.input", lambda _: inp)
|
|
48
|
+
output = helpers.get_input(
|
|
49
|
+
"hello", out_type=out_type, quit_str="q", choices=choices
|
|
50
|
+
)
|
|
51
|
+
assert output == expected
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
@pytest.mark.parametrize(
|
|
55
|
+
"out_type,quit_str,inp,expected",
|
|
56
|
+
[
|
|
57
|
+
(str,"q","hi;there",["hi","there"]),
|
|
58
|
+
(int,"q","q",None),
|
|
59
|
+
]
|
|
60
|
+
)
|
|
61
|
+
def test_get_input_list(monkeypatch, out_type, quit_str: str, inp: str, expected):
|
|
62
|
+
monkeypatch.setattr("builtins.input", lambda _: "q")
|
|
63
|
+
|
|
64
|
+
inputs = helpers.get_input_list(prompt="hello", sep=";", out_type=str, quit_str="q")
|
|
65
|
+
|
|
66
|
+
assert inputs == None
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
@pytest.mark.parametrize(
|
|
70
|
+
"lyst,n_choices,opposite,no_selection_value,return_value,inp,expected",
|
|
71
|
+
[
|
|
72
|
+
(["option1", "option2"], 2, False, None, True, "0;1", ["option1", "option2"]),
|
|
73
|
+
# same as above, but with opposite enabled
|
|
74
|
+
(["option1", "option2"], 2, True, None, True, "0;1", []),
|
|
75
|
+
# same as above, but user uses -1 to quit
|
|
76
|
+
(["option1", "option2"], 2, False, -1, True, "-1", []),
|
|
77
|
+
]
|
|
78
|
+
)
|
|
79
|
+
def test_select_items_from_list(
|
|
80
|
+
monkeypatch,
|
|
81
|
+
lyst: List,
|
|
82
|
+
n_choices: int,
|
|
83
|
+
opposite: Optional[bool],
|
|
84
|
+
no_selection_value,
|
|
85
|
+
return_value: Optional[bool],
|
|
86
|
+
inp,
|
|
87
|
+
expected
|
|
88
|
+
):
|
|
89
|
+
"""parametrized tester for select_items_from_list()"""
|
|
90
|
+
monkeypatch.setattr("builtins.input", lambda _: inp)
|
|
91
|
+
|
|
92
|
+
results = helpers.select_items_from_list(
|
|
93
|
+
"hi",
|
|
94
|
+
lyst=lyst,
|
|
95
|
+
n_choices=n_choices,
|
|
96
|
+
sep=";",
|
|
97
|
+
quit_str="q",
|
|
98
|
+
opposite=opposite,
|
|
99
|
+
no_selection_value=no_selection_value,
|
|
100
|
+
return_value=return_value,
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
assert results == expected
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
version = "0.2.2"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|