Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale_OLD
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
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
jovuit
funkwhale_OLD
Commits
0d3eb96b
Verified
Commit
0d3eb96b
authored
6 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Fixed failing tests
parent
6395f48b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/tests/music/test_metadata.py
+7
-6
7 additions, 6 deletions
api/tests/music/test_metadata.py
api/tests/test_import_audio_file.py
+16
-14
16 additions, 14 deletions
api/tests/test_import_audio_file.py
with
23 additions
and
20 deletions
api/tests/music/test_metadata.py
+
7
−
6
View file @
0d3eb96b
import
datetime
import
os
import
pytest
import
uuid
from
funkwhale_api.music
import
metadata
...
...
@@ -13,9 +14,9 @@ DATA_DIR = os.path.dirname(os.path.abspath(__file__))
(
'
album
'
,
'
Peer Gynt Suite no. 1, op. 46
'
),
(
'
date
'
,
datetime
.
date
(
2012
,
8
,
15
)),
(
'
track_number
'
,
1
),
(
'
musicbrainz_albumid
'
,
'
a766da8b-8336-47aa-a3ee-371cc41ccc75
'
),
(
'
musicbrainz_recordingid
'
,
'
bd21ac48-46d8-4e78-925f-d9cc2a294656
'
),
(
'
musicbrainz_artistid
'
,
'
013c8e5b-d72a-4cd3-8dee-6c64d6125823
'
),
(
'
musicbrainz_albumid
'
,
uuid
.
UUID
(
'
a766da8b-8336-47aa-a3ee-371cc41ccc75
'
)
)
,
(
'
musicbrainz_recordingid
'
,
uuid
.
UUID
(
'
bd21ac48-46d8-4e78-925f-d9cc2a294656
'
)
)
,
(
'
musicbrainz_artistid
'
,
uuid
.
UUID
(
'
013c8e5b-d72a-4cd3-8dee-6c64d6125823
'
)
)
,
])
def
test_can_get_metadata_from_ogg_file
(
field
,
value
):
path
=
os
.
path
.
join
(
DATA_DIR
,
'
test.ogg
'
)
...
...
@@ -30,9 +31,9 @@ def test_can_get_metadata_from_ogg_file(field, value):
(
'
album
'
,
'
You Can
\'
t Stop Da Funk
'
),
(
'
date
'
,
datetime
.
date
(
2006
,
2
,
7
)),
(
'
track_number
'
,
1
),
(
'
musicbrainz_albumid
'
,
'
ce40cdb1-a562-4fd8-a269-9269f98d4124
'
),
(
'
musicbrainz_recordingid
'
,
'
f269d497-1cc0-4ae4-a0c4-157ec7d73fcb
'
),
(
'
musicbrainz_artistid
'
,
'
9c6bddde-6228-4d9f-ad0d-03f6fcb19e13
'
),
(
'
musicbrainz_albumid
'
,
uuid
.
UUID
(
'
ce40cdb1-a562-4fd8-a269-9269f98d4124
'
)
)
,
(
'
musicbrainz_recordingid
'
,
uuid
.
UUID
(
'
f269d497-1cc0-4ae4-a0c4-157ec7d73fcb
'
)
)
,
(
'
musicbrainz_artistid
'
,
uuid
.
UUID
(
'
9c6bddde-6228-4d9f-ad0d-03f6fcb19e13
'
)
)
,
])
def
test_can_get_metadata_from_id3_mp3_file
(
field
,
value
):
path
=
os
.
path
.
join
(
DATA_DIR
,
'
test.mp3
'
)
...
...
This diff is collapsed.
Click to expand it.
api/tests/test_import_audio_file.py
+
16
−
14
View file @
0d3eb96b
...
...
@@ -2,6 +2,8 @@ import pytest
import
acoustid
import
datetime
import
os
import
uuid
from
django.core.management
import
call_command
from
django.core.management.base
import
CommandError
...
...
@@ -15,7 +17,8 @@ DATA_DIR = os.path.join(
def
test_can_create_track_from_file_metadata
(
db
,
mocker
):
mocker
.
patch
(
'
acoustid.match
'
,
side_effect
=
acoustid
.
WebServiceError
(
'
test
'
))
mocker
.
patch
(
'
acoustid.match
'
,
side_effect
=
acoustid
.
WebServiceError
(
'
test
'
))
metadata
=
{
'
artist
'
:
[
'
Test artist
'
],
'
album
'
:
[
'
Test album
'
],
...
...
@@ -35,33 +38,35 @@ def test_can_create_track_from_file_metadata(db, mocker):
os
.
path
.
join
(
DATA_DIR
,
'
dummy_file.ogg
'
))
assert
track
.
title
==
metadata
[
'
title
'
][
0
]
assert
track
.
mbid
==
metadata
[
'
musicbrainz_trackid
'
][
0
]
assert
track
.
mbid
==
uuid
.
UUID
(
metadata
[
'
musicbrainz_trackid
'
][
0
]
)
assert
track
.
position
==
4
assert
track
.
album
.
title
==
metadata
[
'
album
'
][
0
]
assert
track
.
album
.
mbid
==
metadata
[
'
musicbrainz_albumid
'
][
0
]
assert
track
.
album
.
mbid
==
uuid
.
UUID
(
metadata
[
'
musicbrainz_albumid
'
][
0
]
)
assert
track
.
album
.
release_date
==
datetime
.
date
(
2012
,
8
,
15
)
assert
track
.
artist
.
name
==
metadata
[
'
artist
'
][
0
]
assert
track
.
artist
.
mbid
==
metadata
[
'
musicbrainz_artistid
'
][
0
]
assert
track
.
artist
.
mbid
==
uuid
.
UUID
(
metadata
[
'
musicbrainz_artistid
'
][
0
]
)
def
test_management_command_requires_a_valid_username
(
factories
,
mocker
):
path
=
os
.
path
.
join
(
DATA_DIR
,
'
dummy_file.ogg
'
)
user
=
factories
[
'
users.User
'
](
username
=
'
me
'
)
mocker
.
patch
(
'
funkwhale_api.providers.audiofile.management.commands.import_files.Command.do_import
'
)
# NOQA
mocker
.
patch
(
'
funkwhale_api.providers.audiofile.management.commands.import_files.Command.do_import
'
,
# noqa
return_value
=
(
mocker
.
MagicMock
(),
[]))
with
pytest
.
raises
(
CommandError
):
call_command
(
'
import_files
'
,
path
,
username
=
'
not_me
'
,
interactive
=
False
)
call_command
(
'
import_files
'
,
path
,
username
=
'
me
'
,
interactive
=
False
)
def
test_import_files_creates_a_batch_and_job
(
factories
,
mocker
):
m
=
mocker
.
patch
(
'
funkwhale_api.
common.utils.on_commit
'
)
m
=
mocker
.
patch
(
'
funkwhale_api.
music.tasks.import_job_run
'
)
user
=
factories
[
'
users.User
'
](
username
=
'
me
'
)
path
=
os
.
path
.
join
(
DATA_DIR
,
'
dummy_file.ogg
'
)
call_command
(
'
import_files
'
,
path
,
username
=
'
me
'
,
async
=
Tru
e
,
async
=
Fals
e
,
interactive
=
False
)
batch
=
user
.
imports
.
latest
(
'
id
'
)
...
...
@@ -76,26 +81,24 @@ def test_import_files_creates_a_batch_and_job(factories, mocker):
assert
job
.
source
==
'
file://
'
+
path
m
.
assert_called_once_with
(
music_tasks
.
import_job_run
.
delay
,
import_job_id
=
job
.
pk
,
use_acoustid
=
True
)
def
test_import_files_skip_acoustid
(
factories
,
mocker
):
m
=
mocker
.
patch
(
'
funkwhale_api.
common.utils.on_commit
'
)
m
=
mocker
.
patch
(
'
funkwhale_api.
music.tasks.import_job_run
'
)
user
=
factories
[
'
users.User
'
](
username
=
'
me
'
)
path
=
os
.
path
.
join
(
DATA_DIR
,
'
dummy_file.ogg
'
)
call_command
(
'
import_files
'
,
path
,
username
=
'
me
'
,
async
=
Tru
e
,
async
=
Fals
e
,
no_acoustid
=
True
,
interactive
=
False
)
batch
=
user
.
imports
.
latest
(
'
id
'
)
job
=
batch
.
jobs
.
first
()
m
.
assert_called_once_with
(
music_tasks
.
import_job_run
.
delay
,
import_job_id
=
job
.
pk
,
use_acoustid
=
False
)
...
...
@@ -117,20 +120,19 @@ def test_import_files_skip_if_path_already_imported(factories, mocker):
def
test_import_files_works_with_utf8_file_name
(
factories
,
mocker
):
m
=
mocker
.
patch
(
'
funkwhale_api.
common.utils.on_commit
'
)
m
=
mocker
.
patch
(
'
funkwhale_api.
music.tasks.import_job_run
'
)
user
=
factories
[
'
users.User
'
](
username
=
'
me
'
)
path
=
os
.
path
.
join
(
DATA_DIR
,
'
utf8-éà◌.ogg
'
)
call_command
(
'
import_files
'
,
path
,
username
=
'
me
'
,
async
=
Tru
e
,
async
=
Fals
e
,
no_acoustid
=
True
,
interactive
=
False
)
batch
=
user
.
imports
.
latest
(
'
id
'
)
job
=
batch
.
jobs
.
first
()
m
.
assert_called_once_with
(
music_tasks
.
import_job_run
.
delay
,
import_job_id
=
job
.
pk
,
use_acoustid
=
False
)
...
...
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