def test_new_playlist_exists_with_show(self):
     show_id = 'TESTID'
     password = '******'
     with gillard.app.app_context():
         test_utils.make_show(gillard.db.session, show_id, password)
     rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, password))
     assert rv.status_code == 200
    def test_new_playlist_associates_to_show_2X(self):
        show_id = 'TESTID'
        password = '******'
        with gillard.app.app_context():
            test_utils.make_show(gillard.db.session, show_id, password)
        rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, password))
        res_json = json.loads(rv.data.decode("utf-8"))

        with gillard.app.app_context():
            playlist = gillard.db.session.query(Playlist).filter_by(id=1).one()
            show = gillard.db.session.query(Show).filter_by(id=1).one()
            show_playlists = show.playlists

        assert len(show_playlists) == 1

        first_show_playlist = show_playlists[0]

        assert playlist.id == first_show_playlist.id

        rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, password))
        res_json = json.loads(rv.data.decode("utf-8"))

        with gillard.app.app_context():
            playlist = gillard.db.session.query(Playlist).filter_by(id=2).one()
            show = gillard.db.session.query(Show).filter_by(id=1).one()
            show_playlists = show.playlists

        assert len(show_playlists) == 2

        second_show_playlist = show_playlists[1]

        assert playlist.id == second_show_playlist.id
        assert first_show_playlist.id != second_show_playlist.id
 def test_new_playlist_returns_disp(self):
     show_id = 'TESTID'
     password = '******'
     with gillard.app.app_context():
         test_utils.make_show(gillard.db.session, show_id, password)
     rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, password))
     res_json = json.loads(rv.data.decode("utf-8"))
     assert res_json['display_id'] is not None
 def test_new_playlist_errors_on_bad_pw(self):
     show_id = 'TESTID'
     password = '******'
     with gillard.app.app_context():
         test_utils.make_show(gillard.db.session, show_id, password)
     rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, 'FAKEPW'))
     res_json = json.loads(rv.data.decode("utf-8"))
     assert res_json.get('message') == 'No show found for id: TESTID'
 def test_new_playlist_mks_db_record(self):
     show_id = 'TESTID'
     password = '******'
     with gillard.app.app_context():
         test_utils.make_show(gillard.db.session, show_id, password)
     rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, password))
     with gillard.app.app_context():
         playlist = gillard.db.session.query(Playlist).filter_by(id=1).one()
     assert playlist.display_id is not None
 def test_new_playlist_returns_db_record_vals(self):
     show_id = 'TESTID'
     password = '******'
     with gillard.app.app_context():
         test_utils.make_show(gillard.db.session, show_id, password)
     rv = self.app.get('/playlist/new?show_id={}&password={}'.format(show_id, password))
     res_json = json.loads(rv.data.decode("utf-8"))
     with gillard.app.app_context():
         playlist = gillard.db.session.query(Playlist).filter_by(id=1).one()
     assert playlist.display_id == res_json['display_id']
 def test_200(self):
     show_display_id = 'TESTID'
     with gillard.app.app_context():
         show = test_utils.make_show(gillard.db.session, show_display_id)
         playlist = test_utils.make_playlist(gillard.db.session, show)
     rv = self.app.get('/playlists/{}'.format(show_display_id))
     assert rv.status_code == 200
 def test_200(self):
     show_display_id = 'TESTID'
     with gillard.app.app_context():
         show = test_utils.make_show(gillard.db.session, show_display_id)
         playlist = test_utils.make_playlist(gillard.db.session, show)
     rv = self.app.get('/playlists/{}'.format(show_display_id))
     assert rv.status_code == 200
    def test_playlist_delete_song_is_assoc_w_playlist(self):
        with gillard.app.app_context():
            show = test_utils.make_show(gillard.db.session, 'FAKEFAKESHOWID', 'FAKEFAKEPW')
            playlist = test_utils.make_playlist(gillard.db.session, show)
            playlist_display_id = playlist.display_id

            other_playlist = test_utils.make_playlist(gillard.db.session)
            other_playlist_display_id = other_playlist.display_id
            song = test_utils.make_song(gillard.db.session, other_playlist)
            song_id = song.id

        with self.app as app:
            with app.session_transaction() as sess:
                sess['playlist_mode'] = 'edit'

            rv = app.post(
                '/playlist/{}/delete_song'.format(playlist_display_id),
                data=json.dumps(dict(
                    song_id= song_id,
                )),
                content_type = 'application/json'
            )

        res_json = json.loads(rv.data.decode("utf-8"))
        assert res_json['message'] == \
            "Song id {} not in playlist id {}".format(song_id, playlist_display_id)
    def test_playlist_add_song(self):
        show_id = 'TESTID'
        password = '******'
        with gillard.app.app_context():
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            with app.session_transaction() as sess:
                sess['playlist_mode'] = 'edit'

            rv = app.post(
                '/playlist/{}/add_song'.format(playlist.display_id),
                data=json.dumps(dict(
                    artist = 'artist',
                    title = 'title',
                    album = 'album',
                    label = 'label',
                    release_date = 'release_date',
                    notes = 'notes',
                    img64px = 'img64px',
                    img300px = 'img300px',
                    played = True,
                )),
                content_type = 'application/json'
            )

        with gillard.app.app_context():
            show = gillard.db.session.query(Show).filter_by(id=1).one()
            songs = show.playlists[0].songs
            assert len(songs) == 1
    def test_playlist_mode_edit_associates_to_right_playlist_show_link(self):
        bad_show_id = 'BADID'
        bad_password = '******'

        show_id = 'TESTID'
        password = '******'

        with gillard.app.app_context():
            bad_show = test_utils.make_show(gillard.db.session, bad_show_id, bad_password)
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            formatted_url = '/playlist/{}?show_id={}&password={}'.\
                format(playlist.display_id, bad_show_id, bad_password)
            rv = app.get(formatted_url)
            assert session['playlist_mode'] == 'readonly'
 def test_has_show(self):
     show_display_id = 'TESTID'
     with gillard.app.app_context():
         show = test_utils.make_show(gillard.db.session, show_display_id)
         playlist = test_utils.make_playlist(gillard.db.session, show)
     rv = self.app.get('/playlists/{}'.format(show_display_id))
     res_json = json.loads(rv.data.decode("utf-8"))
     assert len(res_json['playlists']) == 1
 def test_has_show(self):
     show_display_id = 'TESTID'
     with gillard.app.app_context():
         show = test_utils.make_show(gillard.db.session, show_display_id)
         playlist = test_utils.make_playlist(gillard.db.session, show)
     rv = self.app.get('/playlists/{}'.format(show_display_id))
     res_json = json.loads(rv.data.decode("utf-8"))
     assert len(res_json['playlists']) == 1
Exemple #14
0
    def test_playlist_mode_edit_associates_to_right_playlist_show_link(self):
        bad_show_id = 'BADID'
        bad_password = '******'

        show_id = 'TESTID'
        password = '******'

        with gillard.app.app_context():
            bad_show = test_utils.make_show(gillard.db.session, bad_show_id,
                                            bad_password)
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            formatted_url = '/playlist/{}?show_id={}&password={}'.\
                format(playlist.display_id, bad_show_id, bad_password)
            rv = app.get(formatted_url)
            assert session['playlist_mode'] == 'readonly'
    def test_playlist_mode_edit_in_session(self):
        show_id = 'TESTID'
        password = '******'
        with gillard.app.app_context():
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            formatted_url = '/playlist/{}?show_id={}&password={}'.\
                format(playlist.display_id, show_id, password)
            rv = app.get(formatted_url)
            assert session['playlist_mode'] == 'edit'
Exemple #16
0
    def test_playlist_mode_edit_in_session(self):
        show_id = 'TESTID'
        password = '******'
        with gillard.app.app_context():
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            formatted_url = '/playlist/{}?show_id={}&password={}'.\
                format(playlist.display_id, show_id, password)
            rv = app.get(formatted_url)
            assert session['playlist_mode'] == 'edit'
    def test_playlist_add_song_readonly_mode(self):
        show_id = 'TESTID'
        password = '******'
        with gillard.app.app_context():
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            with app.session_transaction() as sess:
                sess['playlist_mode'] = 'readonly'

            rv = app.post(
                '/playlist/{}/add_song'.format(playlist.display_id),
                data='not json{}',
                content_type = 'application/json'
            )

        res_json = json.loads(rv.data.decode("utf-8"))
        assert res_json['message'] == "Can't add songs in readonly mode"
    def test_playlist_add_song_response(self):
        show_id = 'TESTID'
        password = '******'
        with gillard.app.app_context():
            show = test_utils.make_show(gillard.db.session, show_id, password)
            playlist = test_utils.make_playlist(gillard.db.session, show)

        with self.app as app:
            with app.session_transaction() as sess:
                sess['playlist_mode'] = 'edit'

            rv = app.post('/playlist/{}/add_song'.format(playlist.display_id), data=json.dumps(dict(
                artist = 'artist',
                title = 'title',
                album = 'album',
                label = 'label',
                release_date = 'release_date',
                notes = 'notes',
                img64px = 'img64px',
                img300px = 'img300px',
                played = True,
            )), content_type = 'application/json')

        assert rv.status_code == 200