Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
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
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
interfect
funkwhale
Commits
c49b8eec
Commit
c49b8eec
authored
4 years ago
by
interfect
Browse files
Options
Downloads
Patches
Plain Diff
Test transcoding from Opus and other formats
parent
9ac829fa
No related branches found
No related tags found
No related merge requests found
Pipeline
#13160
failed
4 years ago
Stage: review
Stage: lint
Stage: test
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
api/tests/music/test_utils.py
+20
-0
20 additions, 0 deletions
api/tests/music/test_utils.py
with
20 additions
and
0 deletions
api/tests/music/test_utils.py
+
20
−
0
View file @
c49b8eec
import
os
import
os
import
pathlib
import
pathlib
import
pytest
import
pytest
import
tempfile
from
funkwhale_api.music
import
utils
from
funkwhale_api.music
import
utils
...
@@ -28,6 +29,7 @@ def test_guess_mimetype_try_using_extension_if_fail(wrong, factories, mocker):
...
@@ -28,6 +29,7 @@ def test_guess_mimetype_try_using_extension_if_fail(wrong, factories, mocker):
(
"
sample.flac
"
,
{
"
bitrate
"
:
1608000
,
"
length
"
:
0.001
}),
(
"
sample.flac
"
,
{
"
bitrate
"
:
1608000
,
"
length
"
:
0.001
}),
(
"
test.mp3
"
,
{
"
bitrate
"
:
8000
,
"
length
"
:
267.70285714285717
}),
(
"
test.mp3
"
,
{
"
bitrate
"
:
8000
,
"
length
"
:
267.70285714285717
}),
(
"
test.ogg
"
,
{
"
bitrate
"
:
112000
,
"
length
"
:
1
}),
(
"
test.ogg
"
,
{
"
bitrate
"
:
112000
,
"
length
"
:
1
}),
(
"
test.opus
"
,
{
"
bitrate
"
:
112000
,
"
length
"
:
1
})
],
],
)
)
def
test_get_audio_file_data
(
name
,
expected
):
def
test_get_audio_file_data
(
name
,
expected
):
...
@@ -109,3 +111,21 @@ def test_get_dirs_and_files(path, expected, tmpdir):
...
@@ -109,3 +111,21 @@ def test_get_dirs_and_files(path, expected, tmpdir):
(
root_path
/
"
System
"
/
"
file.ogg
"
).
touch
()
(
root_path
/
"
System
"
/
"
file.ogg
"
).
touch
()
assert
utils
.
browse_dir
(
root_path
,
path
)
==
expected
assert
utils
.
browse_dir
(
root_path
,
path
)
==
expected
@pytest.mark.parametrize
(
"
name, expected
"
,
[
(
"
sample.flac
"
,
{
"
bitrate
"
:
1608000
,
"
length
"
:
0.001
}),
(
"
test.mp3
"
,
{
"
bitrate
"
:
8000
,
"
length
"
:
267.70285714285717
}),
(
"
test.ogg
"
,
{
"
bitrate
"
:
112000
,
"
length
"
:
1
}),
(
"
test.opus
"
,
{
"
bitrate
"
:
112000
,
"
length
"
:
1
})
],
)
def
test_transcode_file
(
name
,
expected
):
path
=
pathlib
.
Path
(
os
.
path
.
join
(
DATA_DIR
,
name
))
with
tempfile
.
NamedTemporaryFile
()
as
dest
:
utils
.
transcode_file
(
path
,
pathlib
.
Path
(
dest
.
name
))
with
open
(
dest
.
name
,
"
rb
"
)
as
f
:
result
=
utils
.
get_audio_file_data
(
f
)
assert
result
==
expected
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