-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add tag validation to ToontjeHoger(Kids)5Tempo rules
- Loading branch information
1 parent
7a3bba3
commit 7c8365e
Showing
4 changed files
with
125 additions
and
1 deletion.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
backend/experiment/rules/tests/test_toontjehoger_5_tempo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
from django.test import TestCase | ||
|
||
from section.models import Playlist | ||
|
||
from experiment.rules.toontjehoger_5_tempo import ToontjeHoger5Tempo | ||
|
||
|
||
class ToontjeHoger5TempoTest(TestCase): | ||
|
||
def test_validate_playlist_valid(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C3_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C2_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C5_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C5_P2_CH,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C2_P1_CH,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C3_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C2_P2_OR,ch\n" | ||
) | ||
playlist = Playlist.objects.create(name='TestToontjeHoger5Tempo') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_5_tempo_rules = ToontjeHoger5Tempo() | ||
self.assertEqual( | ||
toontje_hoger_5_tempo_rules.validate_playlist(playlist), [] | ||
) | ||
|
||
def test_validate_playlist_invalid_tags(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,F4_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P9_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P2_ZR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C6_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C1_P3_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C1_P1_OZ,ch\n" | ||
) | ||
playlist = Playlist.objects.create(name='TestToontjeHoger5Tempo') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_5_tempo_rules = ToontjeHoger5Tempo() | ||
self.assertEqual( | ||
toontje_hoger_5_tempo_rules.validate_playlist(playlist), | ||
[ | ||
'Invalid tag: C1_P1_OZ', | ||
'Invalid tag: C1_P3_OR', | ||
'Invalid tag: C4_P2_ZR', | ||
'Invalid tag: C4_P9_OR', | ||
'Invalid tag: C6_P1_OR', | ||
'Invalid tag: F4_P2_OR', | ||
] | ||
) |
40 changes: 40 additions & 0 deletions
40
backend/experiment/rules/tests/test_toontjehoger_kids_5_tempo.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from django.test import TestCase | ||
|
||
from section.models import Playlist | ||
|
||
from experiment.rules.toontjehogerkids_5_tempo import ToontjeHogerKids5Tempo | ||
|
||
|
||
class ToontjeHogerKids5TempoTest(TestCase): | ||
|
||
# Toontje Hoger Kids 5 Tempo does not have the strict tag validation | ||
# that Toontje Hoger 5 Tempo has. Therefore, we must ensure that | ||
# the validate_playlist method does not raise any errors for tags | ||
# that would be considered invalid in Toontje Hoger 5 Tempo. | ||
def test_validate_playlist_valid(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C3_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C2_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C5_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C5_P2_CH,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C2_P1_CH,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C3_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C2_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,F4_P2_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P9_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C4_P2_ZR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C6_P1_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C1_P3_OR,ch\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,Eurovision/Set2/Karaoke/2018-11-00-07-046-k.mp3,C1_P1_OZ,ch\n" | ||
) | ||
playlist = Playlist.objects.create(name='TestToontjeHoger5Tempo') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_5_tempo_rules = ToontjeHogerKids5Tempo() | ||
self.assertEqual( | ||
toontje_hoger_5_tempo_rules.validate_playlist(playlist), [] | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters