Exemplo n.º 1
0
 def test_alias_board_uniqueness_conflict(self):
     board = models.Board(name='test',
                          cover=File(name='nessa',
                                     file=open(media_location + 'nessa.jpg',
                                               'rb')))
     board.save()
     clip = models.Clip(name='test',
                        board=board,
                        sound=File(name='dunk',
                                   file=open(media_location + 'school.mp3',
                                             'rb')))
     clip.save()
     clip_to_conflict = models.Clip(
         name='test_conflict',
         board=board,
         sound=File(name='dunk',
                    file=open(media_location + 'school.mp3', 'rb')))
     clip_to_conflict.save()
     alias = models.Alias(name='test_alias', clip=clip)
     alias.save()
     alias_to_conflict = models.Alias(name='test_alias',
                                      clip=clip_to_conflict)
     with pytest.raises(ValidationError):
         alias_to_conflict.save()
     board.delete()
Exemplo n.º 2
0
 def test_playlist_clip_next(self):
     user = User(username="******", password="******")
     user.save()
     playlist = models.Playlist(name="test", user=user)
     playlist.save()
     board = models.Board(name='test',
                          cover=File(name='nessa',
                                     file=open(media_location + 'nessa.jpg',
                                               'rb')))
     board.save()
     clip = models.Clip(name='test',
                        board=board,
                        sound=File(name='dunk',
                                   file=open(media_location + 'school.mp3',
                                             'rb')))
     clip.save()
     clip_next = models.Clip(name='test_next',
                             board=board,
                             sound=File(name='dunk',
                                        file=open(
                                            media_location + 'school.mp3',
                                            'rb')))
     clip_next.save()
     playlist_clip_next = models.PlaylistClip(clip=clip_next,
                                              playlist=playlist,
                                              next=None)
     playlist_clip_next.save()
     playlist_clip = models.PlaylistClip(clip=clip,
                                         playlist=playlist,
                                         next=playlist_clip_next)
     playlist_clip.save()
     board.delete()
Exemplo n.º 3
0
 def test_board(self):
     board = models.Board(name='test',
                          cover=File(name='nessa',
                                     file=open(media_location + 'nessa.jpg',
                                               'rb')))
     board.save()
     assert board.cover.url is not None
     assert board.name == 'test'
     board.delete()
     assert default_storage.exists(board.cover.url) == False
Exemplo n.º 4
0
 def test_clip(self):
     board = models.Board(name='test',
                          cover=File(name='nessa',
                                     file=open(media_location + 'nessa.jpg',
                                               'rb')))
     board.save()
     clip = models.Clip(name='test',
                        board=board,
                        sound=File(name='dunk',
                                   file=open(media_location + 'school.mp3',
                                             'rb')))
     clip.save()
     assert clip.sound.url is not None
     assert clip.name == 'test'
     board.delete()
     assert default_storage.exists(clip.sound.url) == False
Exemplo n.º 5
0
 def test_playlist_clip_uniqueness(self):
     user = User(username="******", password="******")
     user.save()
     playlist = models.Playlist(name="test", user=user)
     playlist.save()
     board = models.Board(name='test',
                          cover=File(name='nessa',
                                     file=open(media_location + 'nessa.jpg',
                                               'rb')))
     board.save()
     clip = models.Clip(name='test',
                        board=board,
                        sound=File(name='dunk',
                                   file=open(media_location + 'school.mp3',
                                             'rb')))
     clip.save()
     playlist_clip = models.PlaylistClip(clip=clip, playlist=playlist)
     playlist_clip.save()
     playlist_clip_to_conflict = models.PlaylistClip(clip=clip,
                                                     playlist=playlist)
     with pytest.raises(IntegrityError):
         playlist_clip_to_conflict.save()
     board.delete()
Exemplo n.º 6
0
 def test_playlist_clip_next_deleted(self):
     user = User(username="******", password="******")
     user.save()
     playlist = models.Playlist(name="test", user=user)
     playlist.save()
     board = models.Board(name='test',
                          cover=File(name='nessa',
                                     file=open(media_location + 'nessa.jpg',
                                               'rb')))
     board.save()
     clip = models.Clip(name='test',
                        board=board,
                        sound=File(name='dunk',
                                   file=open(media_location + 'school.mp3',
                                             'rb')))
     clip.save()
     clip_next = models.Clip(name='test_next',
                             board=board,
                             sound=File(name='dunk',
                                        file=open(
                                            media_location + 'school.mp3',
                                            'rb')))
     clip_next.save()
     playlist_clip_next = models.PlaylistClip(clip=clip_next,
                                              playlist=playlist,
                                              next=None)
     playlist_clip_next.save()
     playlist_clip = models.PlaylistClip(clip=clip,
                                         playlist=playlist,
                                         next=playlist_clip_next)
     playlist_clip.save()
     playlist_clip_next.delete()
     playlist_clip_new_instance = models.PlaylistClip.objects.get(
         clip=clip, playlist=playlist
     )  # Requery because Django model instances persist even after deletion in database
     assert playlist_clip_new_instance.next is None
     board.delete()