Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
cli
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
funkwhale
cli
Commits
ff402d75
Verified
Commit
ff402d75
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Added tests for favorites
parent
3d7fd19c
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
funkwhale_cli/cli.py
+6
-6
6 additions, 6 deletions
funkwhale_cli/cli.py
tests/test_cli.py
+51
-0
51 additions, 0 deletions
tests/test_cli.py
with
57 additions
and
6 deletions
funkwhale_cli/cli.py
+
6
−
6
View file @
ff402d75
...
...
@@ -860,15 +860,15 @@ def favorites(ctx):
@favorites.group
(
"
tracks
"
)
@click.pass_context
def
tracks_
favorites
(
ctx
):
def
favorites
_tracks
(
ctx
):
pass
@
tracks_
favorites.command
(
"
create
"
)
@favorites
_tracks
.command
(
"
create
"
)
@click.argument
(
"
id
"
,
nargs
=-
1
,
required
=
True
)
@click.pass_context
@async_command
async
def
tracks_
favorites_create
(
ctx
,
id
):
async
def
favorites_
tracks_
create
(
ctx
,
id
):
click
.
echo
(
"
Adding {} tracks to favorites…
"
.
format
(
len
(
id
)))
async
with
ctx
.
obj
[
"
remote
"
]:
...
...
@@ -881,11 +881,11 @@ async def tracks_favorites_create(ctx, id):
click
.
echo
(
"
Track {} added to favorites
"
.
format
(
i
))
@
tracks_
favorites.command
(
"
rm
"
)
@favorites
_tracks
.command
(
"
rm
"
)
@click.argument
(
"
id
"
,
nargs
=-
1
,
required
=
True
)
@click.pass_context
@async_command
async
def
tracks_
favorites_rm
(
ctx
,
id
):
async
def
favorites_
tracks_
rm
(
ctx
,
id
):
click
.
echo
(
"
Removing {} tracks to favorites…
"
.
format
(
len
(
id
)))
async
with
ctx
.
obj
[
"
remote
"
]:
...
...
@@ -899,7 +899,7 @@ async def tracks_favorites_rm(ctx, id):
favorites_tracks_ls
=
get_ls_command
(
# noqa
tracks_
favorites
,
favorites
_tracks
,
"
api/v1/favorites/tracks/
"
,
output_conf
=
{
"
labels
"
:
[
"
Track ID
"
,
"
Track
"
,
"
Artist
"
,
"
Favorite Date
"
],
...
...
This diff is collapsed.
Click to expand it.
tests/test_cli.py
+
51
−
0
View file @
ff402d75
...
...
@@ -128,3 +128,54 @@ def test_libraries_rm(cli_ctx, session, responses, get_requests):
assert
len
(
get_requests
(
"
delete
"
,
url
+
"
1/
"
))
==
1
assert
len
(
get_requests
(
"
delete
"
,
url
+
"
42/
"
))
==
1
def
test_favorites_tracks_create
(
cli_ctx
,
session
,
responses
,
get_requests
):
command
=
cli
.
favorites_tracks_create
url
=
"
https://test.funkwhale/api/v1/favorites/tracks/
"
responses
.
post
(
url
,
repeat
=
True
)
command
.
callback
(
id
=
[
1
,
42
],
_async_reraise
=
True
)
requests
=
get_requests
(
"
post
"
,
url
)
assert
len
(
requests
)
==
2
assert
requests
[
0
].
kwargs
[
"
data
"
]
==
{
"
track
"
:
1
}
assert
requests
[
1
].
kwargs
[
"
data
"
]
==
{
"
track
"
:
42
}
def
test_favorites_tracks_ls
(
cli_ctx
,
session
,
responses
,
get_requests
):
command
=
cli
.
favorites_tracks_ls
url
=
"
https://test.funkwhale/api/v1/favorites/tracks/?ordering=-creation_date&page=1&page_size=5&q=hello
"
responses
.
get
(
url
,
payload
=
{
"
results
"
:
[],
"
next
"
:
None
,
"
previous
"
:
None
,
"
count
"
:
0
}
)
command
.
callback
(
raw
=
False
,
page
=
1
,
page_size
=
5
,
ordering
=
"
-creation_date
"
,
filter
=
"
favorites=true
"
,
query
=
[
"
hello
"
],
column
=
None
,
format
=
None
,
no_headers
=
False
,
ids
=
False
,
limit
=
1
,
)
requests
=
get_requests
(
"
get
"
,
url
)
assert
len
(
requests
)
==
1
def
test_favorites_tracks_rm
(
cli_ctx
,
session
,
responses
,
get_requests
):
command
=
cli
.
favorites_tracks_rm
url
=
"
https://test.funkwhale/api/v1/favorites/tracks/remove/
"
responses
.
delete
(
url
,
repeat
=
True
)
command
.
callback
(
id
=
[
1
,
42
],
_async_reraise
=
True
)
requests
=
get_requests
(
"
delete
"
,
url
)
assert
len
(
requests
)
==
2
assert
requests
[
0
].
kwargs
[
"
data
"
]
==
{
"
track
"
:
1
}
assert
requests
[
1
].
kwargs
[
"
data
"
]
==
{
"
track
"
:
42
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment