Exemple #1
0
 def test_get_albums_success(self):
     test_album = Album(title=self.test_album['title'],
                        band_id=self.test_album['band_id'])
     test_album.insert()
     res = self.client().get(
         '/albums',
         headers={"Authorization": "Bearer {}".format(self.manager)})
     self.assertEqual(res.status_code, 200)
     test_album.delete()
def delete_album():
    if not 'MyWebsite_user_id' in session.keys():
        return redirect('/')
    if not User.is_logged_in(session['MyWebsite_user_id'],session['login_session']):
        return redirect('/danger')
    print ("Delete Album: ",request.form['json'])
    deleting_album=json.loads(request.form['json'])
    album_id=deleting_album['album_id']
    Album.delete(album_id)
    return redirect ('/dashboard')
Exemple #3
0
    def test_patch_album_success(self):
        new_album = Album(title=self.test_album['title'],
                          band_id=self.test_album['band_id'])
        new_album.insert()

        res = self.client().patch(
            '/albums/{}'.format(new_album.id),
            json=self.test_album,
            headers={"Authorization": "Bearer {}".format(self.manager)})
        data = json.loads(res.data)
        self.assertEqual(res.status_code, 200)
        self.assertTrue(data['success'])
        new_album.delete()