-
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 pull request #753 from Amsterdam-Music-Lab/fix/session-creation
Fix/session creation
- Loading branch information
Showing
21 changed files
with
293 additions
and
151 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 |
---|---|---|
@@ -0,0 +1,47 @@ | ||
from django.test import TestCase | ||
|
||
from experiment.models import Experiment | ||
from participant.models import Participant | ||
from section.models import Playlist | ||
from session.models import Session | ||
|
||
|
||
class SessionViewsTest(TestCase): | ||
@classmethod | ||
def setUpTestData(cls): | ||
cls.participant = Participant.objects.create(unique_hash=42) | ||
cls.playlist1 = Playlist.objects.create(name='First Playlist') | ||
cls.playlist2 = Playlist.objects.create(name='Second Playlist') | ||
cls.experiment = Experiment.objects.create( | ||
name='TestViews', | ||
slug='testviews' | ||
) | ||
cls.experiment.playlists.add( | ||
cls.playlist1, cls.playlist2 | ||
) | ||
|
||
def setUp(self): | ||
session = self.client.session | ||
session['participant_id'] = self.participant.id | ||
session.save() | ||
|
||
def test_create_with_playlist(self): | ||
request = { | ||
"experiment_id": self.experiment.id, | ||
"playlist_id": self.playlist2.id | ||
} | ||
self.client.post('/session/create/', request) | ||
new_session = Session.objects.get( | ||
experiment=self.experiment, participant=self.participant) | ||
assert new_session | ||
assert new_session.playlist == self.playlist2 | ||
|
||
def test_create_without_playlist(self): | ||
request = { | ||
"experiment_id": self.experiment.id | ||
} | ||
self.client.post('/session/create/', request) | ||
new_session = Session.objects.get( | ||
experiment=self.experiment, participant=self.participant) | ||
assert new_session | ||
assert new_session.playlist == self.playlist1 |
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
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
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.