Beispiel #1
0
 def test_clear_best_friend(self, test_friends):
     """Test clear_best_friend()."""
     bill = test_friends[0]
     rich = test_friends[1]
     rich.friends.append(bill)
     rich.best_friend = bill
     assert dba.clear_best_friend(rich)
     assert rich.best_friend is None
     assert rich.best_friend_id is None
Beispiel #2
0
def remove(monkey_id):
    """Remove a monkey from friends."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    monkey = dba.get_monkey_by_id(monkey_id)

    # Only a friend can be the best friend:
    if monkey is monkey_self.best_friend:
        if not dba.clear_best_friend(monkey_self):
            flash('Error clearing best friend!')

    if not dba.remove_friend(monkey_self, monkey):
        flash('Error removing friend!')
    return redirect(request.referrer or url_for('index'))
Beispiel #3
0
def remove(monkey_id):
    """Remove a monkey from friends."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    monkey = dba.get_monkey_by_id(monkey_id)

    # Only a friend can be the best friend:
    if monkey is monkey_self.best_friend:
        if not dba.clear_best_friend(monkey_self):
            flash('Error clearing best friend!')

    if not dba.remove_friend(monkey_self, monkey):
        flash('Error removing friend!')
    return redirect(request.referrer or url_for('index'))
Beispiel #4
0
def clear_best():
    """Clear your best friend."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    if not dba.clear_best_friend(monkey_self):
        flash('Error clearing best friend!')
    return redirect(request.referrer or url_for('index'))
Beispiel #5
0
def clear_best():
    """Clear your best friend."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    if not dba.clear_best_friend(monkey_self):
        flash('Error clearing best friend!')
    return redirect(request.referrer or url_for('index'))
Beispiel #6
0
 def test_clear_best_friend_none(self):
     """Test clear_best_friend() with None values."""
     monkey = None
     assert not dba.clear_best_friend(monkey)