示例#1
0
    def test_add_friend_none(self, test_monkey):
        """Test add_friend() with None values."""
        bill = None
        rich = None
        assert not dba.add_friend(rich, bill)

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

        bill = None
        rich = test_monkey
        assert not dba.add_friend(rich, bill)
示例#2
0
def add(monkey_id):
    """Add a monkey to friends."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    monkey = dba.get_monkey_by_id(monkey_id)
    if not dba.add_friend(monkey_self, monkey):
        flash('Error adding friend!')
    return redirect(request.referrer or url_for('index'))
示例#3
0
def add(monkey_id):
    """Add a monkey to friends."""
    monkey_self = dba.get_monkey_by_id(session['id'])
    monkey = dba.get_monkey_by_id(monkey_id)
    if not dba.add_friend(monkey_self, monkey):
        flash('Error adding friend!')
    return redirect(request.referrer or url_for('index'))
示例#4
0
 def test_add_friend(self, test_friends):
     """Test add_friend()."""
     bill = test_friends[0]
     rich = test_friends[1]
     assert dba.add_friend(rich, bill)
     assert bill in rich.friends
     assert rich in bill.friend_of