def test_get_bands_success(self): test_band = Band(name=self.test_band['name'], city=self.test_band['city'], state=self.test_band['state']) test_band.insert() res = self.client().get( '/bands', headers={"Authorization": "Bearer {}".format(self.manager)}) self.assertEqual(res.status_code, 200) test_band.delete()
def test_delete_band_success(self): new_band = Band(name=self.test_band['name'], city=self.test_band['city'], state=self.test_band['state']) new_band.insert() res = self.client().delete( '/bands/{}'.format(new_band.id), headers={"Authorization": "Bearer {}".format(self.manager)}) data = json.loads(res.data) self.assertEqual(res.status_code, 200) self.assertTrue(data['success'])
def post_newbands(payload): # takes a JSON object with new artist to add to database body = request.get_json() name = body.get('name', None) city = body.get('city', None) state = body.get('state', None) if name is None: abort(400) if city is None: abort(400) if state is None: abort(400) band = Band(name=name, city=city, state=state) band.insert() new_band = Band.query.get(band.id).format() return jsonify({ 'success': True, 'band': new_band })