def test_remove_friend_none(self, test_monkey): """Test remove_friend() with None values.""" bill = None rich = None assert not dba.remove_friend(rich, bill) bill = test_monkey rich = None assert not dba.remove_friend(rich, bill) bill = None rich = test_monkey assert not dba.remove_friend(rich, bill)
def test_remove_friend(self, test_friends): """Test remove_friend().""" bill = test_friends[0] rich = test_friends[1] rich.friends.append(bill) assert bill in rich.friends assert rich in bill.friend_of assert dba.remove_friend(rich, bill) assert len(list(rich.friends)) == 0 assert len(list(bill.friend_of)) == 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'))