edit_playlist(): Allow moving title to bottom of playlist (#602)
* Allow moving title to bottom of playlist * test_edit_playlist fixed & extended * add labeled coverage workflow run for external PRs * add labeled coverage workflow run for external PRs * add labeled coverage workflow run for external PRs * add another pr target workflow --------- Co-authored-by: Ricardo <ric.ce.br@gmail.com> Co-authored-by: sigma67 <sigma67.github@gmail.com>
This commit is contained in:
parent
33098ba69e
commit
11823d6387
4 changed files with 68 additions and 15 deletions
47
.github/workflows/coverage-pr.yml
vendored
Normal file
47
.github/workflows/coverage-pr.yml
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
name: Code coverage
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request_target:
|
||||||
|
paths:
|
||||||
|
- ytmusicapi/**
|
||||||
|
- tests/**
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@master
|
||||||
|
with:
|
||||||
|
ref: ${{ github.event.pull_request.head.sha }}
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: 3.x
|
||||||
|
- name: Setup PDM
|
||||||
|
uses: pdm-project/setup-pdm@v4
|
||||||
|
- name: create-json
|
||||||
|
uses: jsdaniell/create-json@v1.2.3
|
||||||
|
with:
|
||||||
|
name: "oauth.json"
|
||||||
|
dir: "tests/"
|
||||||
|
json: ${{ secrets.OAUTH_JSON }}
|
||||||
|
- name: Install dependencies
|
||||||
|
run: pdm install
|
||||||
|
- name: Generate coverage report
|
||||||
|
env:
|
||||||
|
HEADERS_AUTH: ${{ secrets.HEADERS_AUTH }}
|
||||||
|
TEST_CFG: ${{ secrets.TEST_CFG }}
|
||||||
|
run: |
|
||||||
|
curl -o tests/test.mp3 https://www.kozco.com/tech/piano2-CoolEdit.mp3
|
||||||
|
cat <<< "$HEADERS_AUTH" > tests/browser.json
|
||||||
|
cat <<< "$TEST_CFG" > tests/test.cfg
|
||||||
|
(echo "===== tests attempt: 1 ====" && pdm run pytest) || \
|
||||||
|
(echo "===== tests attempt: 2 ====" && pdm run pytest)
|
||||||
|
pdm run coverage xml
|
||||||
|
- name: Upload coverage to Codecov
|
||||||
|
uses: codecov/codecov-action@v4
|
||||||
|
with:
|
||||||
|
file: coverage.xml
|
||||||
|
flags: unittests
|
||||||
|
fail_ci_if_error: true
|
||||||
|
token: ${{ secrets.CODECOV_TOKEN }}
|
||||||
4
.github/workflows/coverage.yml
vendored
4
.github/workflows/coverage.yml
vendored
|
|
@ -7,9 +7,7 @@ on:
|
||||||
paths:
|
paths:
|
||||||
- ytmusicapi/**
|
- ytmusicapi/**
|
||||||
- tests/**
|
- tests/**
|
||||||
pull_request:
|
pull_request_target:
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
paths:
|
paths:
|
||||||
- ytmusicapi/**
|
- ytmusicapi/**
|
||||||
- tests/**
|
- tests/**
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,7 @@ class TestPlaylists:
|
||||||
|
|
||||||
def test_edit_playlist(self, config, yt_brand):
|
def test_edit_playlist(self, config, yt_brand):
|
||||||
playlist = yt_brand.get_playlist(config["playlists"]["own"])
|
playlist = yt_brand.get_playlist(config["playlists"]["own"])
|
||||||
response = yt_brand.edit_playlist(
|
response1 = yt_brand.edit_playlist(
|
||||||
playlist["id"],
|
playlist["id"],
|
||||||
title="",
|
title="",
|
||||||
description="",
|
description="",
|
||||||
|
|
@ -76,8 +76,8 @@ class TestPlaylists:
|
||||||
playlist["tracks"][0]["setVideoId"],
|
playlist["tracks"][0]["setVideoId"],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert response == "STATUS_SUCCEEDED", "Playlist edit failed"
|
assert response1 == "STATUS_SUCCEEDED", "Playlist edit 1 failed"
|
||||||
yt_brand.edit_playlist(
|
response2 = yt_brand.edit_playlist(
|
||||||
playlist["id"],
|
playlist["id"],
|
||||||
title=playlist["title"],
|
title=playlist["title"],
|
||||||
description=playlist["description"],
|
description=playlist["description"],
|
||||||
|
|
@ -87,7 +87,15 @@ class TestPlaylists:
|
||||||
playlist["tracks"][1]["setVideoId"],
|
playlist["tracks"][1]["setVideoId"],
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
assert response == "STATUS_SUCCEEDED", "Playlist edit failed"
|
assert response2 == "STATUS_SUCCEEDED", "Playlist edit 2 failed"
|
||||||
|
response3 = yt_brand.edit_playlist(
|
||||||
|
playlist["id"],
|
||||||
|
title=playlist["title"],
|
||||||
|
description=playlist["description"],
|
||||||
|
privacyStatus=playlist["privacy"],
|
||||||
|
moveItem=playlist["tracks"][0]["setVideoId"],
|
||||||
|
)
|
||||||
|
assert response3 == "STATUS_SUCCEEDED", "Playlist edit 3 failed"
|
||||||
|
|
||||||
def test_end2end(self, yt_brand, sample_video):
|
def test_end2end(self, yt_brand, sample_video):
|
||||||
playlist_id = yt_brand.create_playlist(
|
playlist_id = yt_brand.create_playlist(
|
||||||
|
|
|
||||||
|
|
@ -327,7 +327,7 @@ class PlaylistsMixin(MixinProtocol):
|
||||||
title: Optional[str] = None,
|
title: Optional[str] = None,
|
||||||
description: Optional[str] = None,
|
description: Optional[str] = None,
|
||||||
privacyStatus: Optional[str] = None,
|
privacyStatus: Optional[str] = None,
|
||||||
moveItem: Optional[Tuple[str, str]] = None,
|
moveItem: Optional[Union[str, Tuple[str, str]]] = None,
|
||||||
addPlaylistId: Optional[str] = None,
|
addPlaylistId: Optional[str] = None,
|
||||||
addToTop: Optional[bool] = None,
|
addToTop: Optional[bool] = None,
|
||||||
) -> Union[str, Dict]:
|
) -> Union[str, Dict]:
|
||||||
|
|
@ -358,13 +358,13 @@ class PlaylistsMixin(MixinProtocol):
|
||||||
actions.append({"action": "ACTION_SET_PLAYLIST_PRIVACY", "playlistPrivacy": privacyStatus})
|
actions.append({"action": "ACTION_SET_PLAYLIST_PRIVACY", "playlistPrivacy": privacyStatus})
|
||||||
|
|
||||||
if moveItem:
|
if moveItem:
|
||||||
actions.append(
|
action = {
|
||||||
{
|
"action": "ACTION_MOVE_VIDEO_BEFORE",
|
||||||
"action": "ACTION_MOVE_VIDEO_BEFORE",
|
"setVideoId": moveItem if isinstance(moveItem, str) else moveItem[0],
|
||||||
"setVideoId": moveItem[0],
|
}
|
||||||
"movedSetVideoIdSuccessor": moveItem[1],
|
if isinstance(moveItem, tuple) and len(moveItem) > 1:
|
||||||
}
|
action["movedSetVideoIdSuccessor"] = moveItem[1]
|
||||||
)
|
actions.append(action)
|
||||||
|
|
||||||
if addPlaylistId:
|
if addPlaylistId:
|
||||||
actions.append({"action": "ACTION_ADD_PLAYLIST", "addedFullListId": addPlaylistId})
|
actions.append({"action": "ACTION_ADD_PLAYLIST", "addedFullListId": addPlaylistId})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue