Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
funkwhale
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
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
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
David Marzal
funkwhale
Commits
244ebd7a
Verified
Commit
244ebd7a
authored
7 years ago
by
Eliot Berriot
Browse files
Options
Downloads
Patches
Plain Diff
Dropped hard constraint on track indexes and added more tests
parent
8ff775a1
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/funkwhale_api/playlists/migrations/0004_auto_20180320_1713.py
+5
-1
5 additions, 1 deletion
...whale_api/playlists/migrations/0004_auto_20180320_1713.py
api/tests/playlists/test_models.py
+20
-6
20 additions, 6 deletions
api/tests/playlists/test_models.py
with
25 additions
and
7 deletions
api/funkwhale_api/playlists/migrations/0004_auto_201803
19_1642
.py
→
api/funkwhale_api/playlists/migrations/0004_auto_201803
20_1713
.py
+
5
−
1
View file @
244ebd7a
# Generated by Django 2.0.3 on 2018-03-
19 16:42
# Generated by Django 2.0.3 on 2018-03-
20 17:13
from
django.db
import
migrations
,
models
...
...
@@ -20,4 +20,8 @@ class Migration(migrations.Migration):
name
=
'
index
'
,
field
=
models
.
PositiveIntegerField
(
blank
=
True
,
null
=
True
),
),
migrations
.
AlterUniqueTogether
(
name
=
'
playlisttrack
'
,
unique_together
=
set
(),
),
]
This diff is collapsed.
Click to expand it.
api/tests/playlists/test_models.py
+
20
−
6
View file @
244ebd7a
...
...
@@ -44,12 +44,9 @@ def test_can_insert_at_index(factories):
def
test_can_insert_and_move
(
factories
):
playlist
=
factories
[
'
playlists.Playlist
'
]()
first
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
)
second
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
)
third
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
)
playlist
.
insert
(
first
)
playlist
.
insert
(
second
)
playlist
.
insert
(
third
)
first
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
,
index
=
0
)
second
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
,
index
=
1
)
third
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
,
index
=
2
)
playlist
.
insert
(
second
,
index
=
0
)
...
...
@@ -62,6 +59,23 @@ def test_can_insert_and_move(factories):
assert
first
.
index
==
1
def
test_can_insert_and_move_last_to_0
(
factories
):
playlist
=
factories
[
'
playlists.Playlist
'
]()
first
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
,
index
=
0
)
second
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
,
index
=
1
)
third
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
playlist
,
index
=
2
)
playlist
.
insert
(
third
,
index
=
0
)
first
.
refresh_from_db
()
second
.
refresh_from_db
()
third
.
refresh_from_db
()
assert
third
.
index
==
0
assert
first
.
index
==
1
assert
second
.
index
==
2
def
test_cannot_insert_at_wrong_index
(
factories
):
plt
=
factories
[
'
playlists.PlaylistTrack
'
]()
new
=
factories
[
'
playlists.PlaylistTrack
'
](
playlist
=
plt
.
playlist
)
...
...
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