def test_undisbursed_challenges(app):
    setup_challenges(app)
    with app.app_context():
        db = get_db()
    with db.scoped_session() as session:
        undisbursed = get_undisbursed_challenges(session, {'user_id': None, 'limit': 10, 'offset': 0, 'completed_blocknumber': 99})
        expected = [{'challenge_id': 'test_challenge_3', 'user_id': 6, 'specifier': '6', 'amount': '5', 'completed_blocknumber': 100, 'handle': 'TestHandle6', 'wallet': '0x6'}, {'challenge_id': 'test_challenge_2', 'user_id': 4, 'specifier': '4', 'amount': '5', 'completed_blocknumber': 102, 'handle': 'TestHandle4', 'wallet': '0x4'}, {'challenge_id': 'test_challenge_2', 'user_id': 5, 'specifier': '5', 'amount': '5', 'completed_blocknumber': 102, 'handle': 'TestHandle5', 'wallet': '0x5'}]
        assert (expected == undisbursed)
        undisbursed = get_undisbursed_challenges(session, {'user_id': 6, 'limit': 10, 'offset': 0, 'completed_blocknumber': 99})
        expected = [{'challenge_id': 'test_challenge_3', 'user_id': 6, 'specifier': '6', 'amount': '5', 'completed_blocknumber': 100, 'handle': 'TestHandle6', 'wallet': '0x6'}]
        assert (expected == undisbursed)
        undisbursed = get_undisbursed_challenges(session, {'user_id': 6, 'limit': 10, 'offset': 0, 'completed_blocknumber': 101})
        expected = []
        assert (expected == undisbursed)
def test_undisbursed_challenges(app):
    setup_challenges(app)
    with app.app_context():
        db = get_db()
    with db.scoped_session() as session:
        undisbursed = get_undisbursed_challenges(session, {'user_id': None, 'limit': 10, 'offset': 0, 'completed_blocknumber': 99})
        expected = [{'challenge_id': 'test_challenge_3', 'user_id': 6, 'specifier': '6', 'amount': '5', 'completed_blocknumber': 100, 'handle': 'TestHandle6', 'wallet': '0x6'}, {'challenge_id': 'test_challenge_2', 'user_id': 4, 'specifier': '4', 'amount': '5', 'completed_blocknumber': 102, 'handle': 'TestHandle4', 'wallet': '0x4'}, {'challenge_id': 'test_challenge_2', 'user_id': 5, 'specifier': '5', 'amount': '5', 'completed_blocknumber': 102, 'handle': 'TestHandle5', 'wallet': '0x5'}]
        assert (expected == undisbursed)
        undisbursed = get_undisbursed_challenges(session, {'user_id': 6, 'limit': 10, 'offset': 0, 'completed_blocknumber': 99})
        expected = [{'challenge_id': 'test_challenge_3', 'user_id': 6, 'specifier': '6', 'amount': '5', 'completed_blocknumber': 100, 'handle': 'TestHandle6', 'wallet': '0x6'}]
        assert (expected == undisbursed)
        undisbursed = get_undisbursed_challenges(session, {'user_id': 6, 'limit': 10, 'offset': 0, 'completed_blocknumber': 101})
        expected = []
        assert (expected == undisbursed)