Esempio n. 1
0
    def test_set_best_friend_none(self, test_monkey):
        """Test set_best_friend() with None values."""
        bill = None
        rich = None
        assert not dba.set_best_friend(rich, bill)

        bill = test_monkey
        rich = None
        assert not dba.set_best_friend(rich, bill)

        bill = None
        rich = test_monkey
        assert not dba.set_best_friend(rich, bill)
Esempio n. 2
0
def best(monkey_id):
    """Make a monkey your best friend."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    monkey = dba.get_monkey_by_id(monkey_id)
    if not dba.set_best_friend(monkey_self, monkey):
        flash('Error setting best friend!')
    return redirect(request.referrer or url_for('index'))
Esempio n. 3
0
def best(monkey_id):
    """Make a monkey your best friend."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    monkey = dba.get_monkey_by_id(monkey_id)
    if not dba.set_best_friend(monkey_self, monkey):
        flash('Error setting best friend!')
    return redirect(request.referrer or url_for('index'))
Esempio n. 4
0
 def test_set_best_friend(self, test_friends):
     """Test set_best_friend()."""
     bill = test_friends[0]
     rich = test_friends[1]
     rich.friends.append(bill)
     assert dba.set_best_friend(rich, bill)
     assert rich.best_friend is bill
     assert rich.best_friend_id == bill.id