-
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.
Merge branch 'develop' into fix/logos
- Loading branch information
Showing
18 changed files
with
383 additions
and
30 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -195,4 +195,4 @@ | |
} | ||
} | ||
|
||
SUBPATH = os.getenv('AML_SUBPATH', None) | ||
SUBPATH = os.getenv('AML_SUBPATH', '') |
File renamed without changes.
105 changes: 105 additions & 0 deletions
105
backend/experiment/rules/tests/test_toontjehoger_4_absolute.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,105 @@ | ||
from unittest.mock import patch | ||
|
||
from django.test import TestCase | ||
|
||
from section.models import Playlist as PlaylistModel | ||
|
||
from experiment.rules.toontjehoger_4_absolute import ToontjeHoger4Absolute | ||
|
||
|
||
class TestToontjeHoger4Absolute(TestCase): | ||
|
||
def setUp(self): | ||
# Mock the file_exists_validator function from section.models | ||
# instead of section.validators as it is imported in the Playlist class | ||
# which is in the section.models module | ||
patcher = patch('section.models.file_exists_validator') | ||
self.mock_file_exists_validator = patcher.start() | ||
self.mock_file_exists_validator.return_value = None | ||
self.addCleanup(patcher.stop) | ||
|
||
def test_initializes_correctly(self): | ||
toontje_hoger_4_absolute = ToontjeHoger4Absolute() | ||
assert toontje_hoger_4_absolute.ID == 'TOONTJE_HOGER_4_ABSOLUTE' | ||
|
||
def test_validate_valid_playlist(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-1.mp3,a,1\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-2.mp3,c,2\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-10.mp3,b,10\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-3.mp3,a,3\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-8.mp3,b,8\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-4.mp3,b,4\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-5.mp3,c,5\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-9.mp3,b,9\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-6.mp3,b,6\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-7.mp3,b,7\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-11.mp3,b,11\n" | ||
) | ||
playlist = PlaylistModel.objects.create(name='TestToontjeHoger4Absolute') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_4_absolute = ToontjeHoger4Absolute() | ||
self.assertEqual( | ||
toontje_hoger_4_absolute.validate_playlist(playlist), [] | ||
) | ||
|
||
def test_validate_invalid_integer_groups(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-1.mp3,a,a\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-2.mp3,c,2\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-3.mp3,a,4\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-4.mp3,b,4\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-5.mp3,c,11\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-6.mp3,b,7\n" | ||
) | ||
playlist = PlaylistModel.objects.create(name='TestToontjeHoger4Absolute') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_4_absolute = ToontjeHoger4Absolute() | ||
|
||
self.assertEqual( | ||
toontje_hoger_4_absolute.validate_playlist(playlist), | ||
["Groups in playlist sections should be numbers. This playlist has groups: ['a', '2', '4', '4', '11', '7']"] | ||
) | ||
|
||
def test_validate_invalid_sequential_groups(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-1.mp3,a,8\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-2.mp3,c,3\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-3.mp3,a,3\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-4.mp3,b,4\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-5.mp3,c,11\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-6.mp3,b,1\n" | ||
) | ||
playlist = PlaylistModel.objects.create(name='TestToontjeHoger4Absolute') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_4_absolute = ToontjeHoger4Absolute() | ||
|
||
self.assertEqual( | ||
toontje_hoger_4_absolute.validate_playlist(playlist), | ||
['Groups in playlist sections should be sequential numbers starting from 1 to the number of sections in the playlist (6). E.g. "1, 2, 3, ... 6"'] | ||
) | ||
|
||
def test_validate_invalid_tags(self): | ||
csv_data = ( | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-1.mp3,a,1\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-2.mp3,c,2\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-3.mp3,a,3\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-4.mp3,b,4\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-5.mp3,c,5\n" | ||
"Albania 2018 - Eugent Bushpepa,Mall,7.046,45.0,ToontjeHoger4Absolute/audio-6.mp3,d,6\n" | ||
) | ||
playlist = PlaylistModel.objects.create(name='TestToontjeHoger4AbsoluteInvalidTags') | ||
playlist.csv = csv_data | ||
playlist.update_sections() | ||
|
||
toontje_hoger_4_absolute = ToontjeHoger4Absolute() | ||
self.assertEqual( | ||
toontje_hoger_4_absolute.validate_playlist(playlist), | ||
['Tags in playlist sections should be \'a\', \'b\' or \'c\'. This playlist has tags: [\'a\', \'b\', \'c\', \'d\']'] | ||
) |
83 changes: 83 additions & 0 deletions
83
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,83 @@ | ||
from unittest.mock import patch | ||
|
||
from django.test import TestCase | ||
|
||
from section.models import Playlist | ||
|
||
from experiment.rules.toontjehoger_5_tempo import ToontjeHoger5Tempo | ||
|
||
|
||
class TestToontjeHoger5Tempo(TestCase): | ||
|
||
def setUp(self): | ||
# Mock the file_exists_validator function from section.models | ||
# instead of section.validators as it is imported in the Playlist class | ||
# which is in the section.models module | ||
patcher = patch('section.models.file_exists_validator') | ||
self.mock_file_exists_validator = patcher.start() | ||
self.mock_file_exists_validator.return_value = None | ||
self.addCleanup(patcher.stop) | ||
|
||
def test_validate_playlist_valid(self): | ||
csv_data = ( | ||
"song-01,artist-01,7.046,45.0,ToontjeHoger5Tempo/song-01.mp3,C3_P2_OR,ch\n" | ||
"song-02,artist-02,7.046,45.0,ToontjeHoger5Tempo/song-02.mp3,C2_P1_OR,ch\n" | ||
"song-03,artist-03,7.046,45.0,ToontjeHoger5Tempo/song-03.mp3,C4_P2_OR,ch\n" | ||
"song-04,artist-04,7.046,45.0,ToontjeHoger5Tempo/song-04.mp3,C4_P2_OR,ch\n" | ||
"song-05,artist-05,7.046,45.0,ToontjeHoger5Tempo/song-05.mp3,C5_P2_OR,or\n" | ||
"song-06,artist-06,7.046,45.0,ToontjeHoger5Tempo/song-06.mp3,C5_P2_CH,or\n" | ||
"song-07,artist-07,7.046,45.0,ToontjeHoger5Tempo/song-07.mp3,C4_P1_OR,or\n" | ||
"song-08,artist-08,7.046,45.0,ToontjeHoger5Tempo/song-08.mp3,C2_P1_CH,or\n" | ||
"song-09,artist-09,7.046,45.0,ToontjeHoger5Tempo/song-09.mp3,C3_P1_OR,or\n" | ||
"song-10,artist-10,7.046,45.0,ToontjeHoger5Tempo/song-10.mp3,C2_P2_OR,or\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 = ( | ||
"song-01,artist-01,7.046,45.0,ToontjeHoger5Tempo/song-01.mp3,F4_P2_OR,ch\n" | ||
"song-02,artist-02,7.046,45.0,ToontjeHoger5Tempo/song-02.mp3,C4_P9_OR,ch\n" | ||
"song-03,artist-03,7.046,45.0,ToontjeHoger5Tempo/song-03.mp3,C4_P2_ZR,ch\n" | ||
"song-04,artist-04,7.046,45.0,ToontjeHoger5Tempo/song-04.mp3,C6_P1_OR,or\n" | ||
"song-05,artist-05,7.046,45.0,ToontjeHoger5Tempo/song-05.mp3,C1_P3_OR,or\n" | ||
"song-06,artist-06,7.046,45.0,ToontjeHoger5Tempo/song-06.mp3,C1_P1_OZ,or\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), | ||
[ | ||
"Tags should start with either 'C', 'J' or 'R', followed by a number between " | ||
"1 and 5, followed by '_P', followed by either 1 or 2, followed by either " | ||
"'_OR' or '_CH'. Invalid tags: C1_P1_OZ, C1_P3_OR, C4_P2_ZR, C4_P9_OR, " | ||
'C6_P1_OR, F4_P2_OR' | ||
] | ||
) | ||
|
||
def test_validate_playlist_invalid_groups(self): | ||
csv_data = ( | ||
"song-01,artist-01,7.046,45.0,ToontjeHoger5Tempo/song-01.mp3,C3_P2_OR,ch\n" | ||
"song-02,artist-02,7.046,45.0,ToontjeHoger5Tempo/song-02.mp3,C2_P1_OR,ch\n" | ||
"song-03,artist-03,7.046,45.0,ToontjeHoger5Tempo/song-03.mp3,C4_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), | ||
[ | ||
"The playlist must contain two groups: 'or' and 'ch'. Found: ['ch']" | ||
] | ||
) |
51 changes: 51 additions & 0 deletions
51
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,51 @@ | ||
from unittest.mock import patch | ||
|
||
from django.test import TestCase | ||
|
||
from section.models import Playlist | ||
|
||
from experiment.rules.toontjehogerkids_5_tempo import ToontjeHogerKids5Tempo | ||
|
||
|
||
class ToontjeHogerKids5TempoTest(TestCase): | ||
|
||
def setUp(self): | ||
# Mock the file_exists_validator function from section.models | ||
# instead of section.validators as it is imported in the Playlist class | ||
# which is in the section.models module | ||
patcher = patch('section.models.file_exists_validator') | ||
self.mock_file_exists_validator = patcher.start() | ||
self.mock_file_exists_validator.return_value = None | ||
self.addCleanup(patcher.stop) | ||
|
||
# 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 = ( | ||
"song-01,artist-01,7.046,45.0,ToontjeHoger5Tempo/song-01.mp3,C3_P2_OR,ch\n" | ||
"song-02,artist-02,7.046,45.0,ToontjeHoger5Tempo/song-02.mp3,C2_P1_OR,ch\n" | ||
"song-03,artist-03,7.046,45.0,ToontjeHoger5Tempo/song-03.mp3,C4_P2_OR,ch\n" | ||
"song-04,artist-04,7.046,45.0,ToontjeHoger5Tempo/song-04.mp3,C4_P2_OR,ch\n" | ||
"song-05,artist-05,7.046,45.0,ToontjeHoger5Tempo/song-05.mp3,C5_P2_OR,ch\n" | ||
"song-06,artist-06,7.046,45.0,ToontjeHoger5Tempo/song-06.mp3,C5_P2_CH,ch\n" | ||
"song-07,artist-07,7.046,45.0,ToontjeHoger5Tempo/song-07.mp3,C4_P1_OR,ch\n" | ||
"song-08,artist-08,7.046,45.0,ToontjeHoger5Tempo/song-08.mp3,C2_P1_CH,or\n" | ||
"song-09,artist-09,7.046,45.0,ToontjeHoger5Tempo/song-09.mp3,C3_P1_OR,or\n" | ||
"song-10,artist-10,7.046,45.0,ToontjeHoger5Tempo/song-10.mp3,C2_P2_OR,or\n" | ||
"song-11,artist-11,7.046,45.0,ToontjeHoger5Tempo/song-11.mp3,F4_P2_OR,or\n" | ||
"song-12,artist-12,7.046,45.0,ToontjeHoger5Tempo/song-12.mp3,C4_P9_OR,or\n" | ||
"song-13,artist-13,7.046,45.0,ToontjeHoger5Tempo/song-13.mp3,C4_P2_ZR,or\n" | ||
"song-14,artist-14,7.046,45.0,ToontjeHoger5Tempo/song-14.mp3,C6_P1_OR,or\n" | ||
"song-15,artist-15,7.046,45.0,ToontjeHoger5Tempo/song-15.mp3,C1_P3_OR,or\n" | ||
"song-16,artist-16,7.046,45.0,ToontjeHoger5Tempo/song-16.mp3,C1_P1_OZ,or\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
Oops, something went wrong.