def test_get_happy(): result = get_music('happy', limit=1) for playlist in result: # make sure every playlist has the word 'happy' in its name print playlist assert 'happy' in playlist.get('name').lower()
def music(): mood = request.form.get('mood') music = get_music(mood) # Store the mood in the session so we don't need to send it up all the time session['mood'] = mood print '$$$$$$$$$$$$$$$$$$$$ music done $$$$$$$$$$$$$$$$$$$' return render_template('music.html', music=music)
def music(): print " ENTERING /MUSIC ROUTE" mood = request.form.get('mood') music = get_music(mood) # Store the mood in the session so we don't need to send it up all the time session['mood'] = mood return render_template('music.html', music=music)
def music_api(): offset = request.form.get('offset') mood = session.get('mood') # We can skip arguments with defaults - we don't need to supply 'limit' # but we do need to specify that the thing we're sending is 'offset' music = get_music(mood, offset=offset) return jsonify({'playlists': music}) # you can't just jsonify a list
def music_api(): print "***********ENTERING API/MUSIC ROUTE ********** " offset = request.form.get('offset') mood = session.get('mood') # We can skip arguments with defaults - we don't need to supply 'limit' # but we do need to specify that the thing we're sending is 'offset' music = get_music(mood, offset=offset) print " HERE 'S the RESULTS " print music print return jsonify({'playlists': music}) # you can't just jsonify a list
def test_get_limit(): # test that if we have a limit of 20 we get 20 results result = get_music("happy", limit=20) assert len(result) == 20
def test_get_happy(): result = get_music("happy") for playlist in result: # make sure every playlist has the word 'happy' in its name assert "happy" in playlist.get("name").lower()
def test_get_limit(): # test that if we have a limit of 20 we get 20 results result = get_music('happy', limit=1) assert len(result) == 1