def test_getBoardsDetailed(): boardsdetail = board.getBoardsDetailed() assert len(boardsdetail) == len(board.getBoards()) for boardName in board.getBoards(): assert boardName in [i["filename"] for i in boardsdetail] for item in boardsdetail: for key in item: assert item[key] == board.getBoardAttr(item["filename"],key)
def test_getPost(): for boardName in board.getBoards(): l = boardDIR.getPostsList( boardName ) for thePost in l: filename = thePost["filename"] content = post.getPost(boardName,filename) assert type(content) == str
def test_getPost(): for boardName in board.getBoards(): l = boardDIR.getPostsList(boardName) for thePost in l: filename = thePost["filename"] content = post.getPost(boardName, filename) assert type(content) == str
def test_getBoardDetailed(): boards = board.getBoards() for b in boards: item = board.getBoardDetailed(b) for key in item: assert item[key] == board.getBoardAttr(item["filename"],key) assert not board.getBoardDetailed("not exist")
def test_getPostNoCT(): for boardName in board.getBoards(): l = boardDIR.getPostsList(boardName) for thePost in l: filename = thePost["filename"] content = post.getPostNoCT(boardName, filename) assert not re.search('\\033\[[0-9;]*[a-zA-Z]', content) assert type(content) == str
def test_getPostNoCT(): for boardName in board.getBoards(): l = boardDIR.getPostsList( boardName ) for thePost in l: filename = thePost["filename"] content = post.getPostNoCT(boardName,filename) assert not re.search('\\033\[[0-9;]*[a-zA-Z]',content) assert type(content) == str
def boardPage(board): """ Routes to the index page of a board. Prints a list of threads and the last few replies to that thread. """ b = getBoards(get_db())[board] posts = b.getPosts(get_db()) app.logger.info("Retrieving " + str(len(posts)) + " posts") return render_template("board.html", board=board, post_list=posts)
def test_getPostNoCTEscape(): for boardName in board.getBoards(): l = boardDIR.getPostsList( boardName ) for thePost in l: filename = thePost["filename"] content = post.getPostNoCTEscape(boardName,filename) assert not re.search('\\\\x1b\[[0-9;]*[a-zA-Z]',content) for i in content: assert ord(i) < 128 assert ord(i) >= 32
def test_getPostEscape(): for boardName in board.getBoards(): l = boardDIR.getPostsList( boardName ) for thePost in l: filename = thePost["filename"] content = post.getPostEscape(boardName,filename) for i in content: assert ord(i) < 128 assert ord(i) >= 32
def test_getPostEscape(): for boardName in board.getBoards(): l = boardDIR.getPostsList(boardName) for thePost in l: filename = thePost["filename"] content = post.getPostEscape(boardName, filename) for i in content: assert ord(i) < 128 assert ord(i) >= 32
def test_getPostNoCTEscape(): for boardName in board.getBoards(): l = boardDIR.getPostsList(boardName) for thePost in l: filename = thePost["filename"] content = post.getPostNoCTEscape(boardName, filename) assert not re.search('\\\\x1b\[[0-9;]*[a-zA-Z]', content) for i in content: assert ord(i) < 128 assert ord(i) >= 32
def resPage(board, number): """ Gets the page of a thread for responses to that thread. Prints all of the responses. """ b = getBoards(get_db())[board] post = b.getPosts(get_db())[int(number)] if post == None: return "<center><h1>404</h1></center>" else: return render_template("board.html", board=board, post_list={post.number : post}, number=number)
def test_getBoardAttr(): boards = board.getBoards() for b in boards: num = board.getBoardAttr(b,"group") assert num >= 0 assert type(num) == int or type(num) == long s = board.getBoardAttr(b,"title") assert len(s) > 0 assert type(s) == str s = board.getBoardAttr(b,"BM") assert len(s) >= 0 assert re.search(r"^[a-zA-Z ]*$",s) assert type(s) == str num = board.getBoardAttr(b,"level") assert num >= 0 assert type(num) == int or type(num) == long s = board.getBoardAttr(b,"filename") assert s in board.getBoards() assert re.search(r"^[a-zA-Z0-9]{1,14}$",s) assert type(s) == str s = board.getBoardAttr(b,"flag") assert type(s) == str s = board.getBoardAttr(b,"flag2") assert type(s) == str s = board.getBoardAttr(b,"owner") assert re.search(r"^[a-zA-Z ]*$",s) assert type(s) == str s = board.getBoardAttr(b,"accessed") assert type(s) == str
def resPage(board, number): """ Gets the page of a thread for responses to that thread. Prints all of the responses. """ b = getBoards(get_db())[board] post = b.getPosts(get_db())[int(number)] if post == None: return "<center><h1>404</h1></center>" else: return render_template("board.html", board=board, post_list={post.number: post}, number=number)
def test_getPostsList(): for boardName in board.getBoards(): l = boardDIR.getPostsList( boardName ) assert boardName and len(l) > 0 for thePost in l: num = thePost["pnum"] assert num >= 0 assert type(num) == int or type(num) == long num = thePost["level"] assert num >= 0 assert type(num) == int or type(num) == long s = thePost["filename"] assert len(s) >= 0 assert re.search(r"^[A-Z]\.[0-9]{8,11}\.[A-Z]$",s) assert type(s) == str s = thePost["title"] assert len(s) >= 0 assert type(s) == str num = thePost["reid"] assert num >= 10**9 or num == 0 assert num <= 10**9*2 assert type(num) == int or type(num) == long s = thePost["owner"] assert len(s) >= 0 assert re.search(r"^[a-zA-Z0-9\.]{2,14}$",s) assert type(s) == str s = thePost["accessed"] assert len(s) >= 0 assert type(s) == str num = thePost["id"] assert num >= 10**9 or num == 0 assert num <= 10**9*2 assert re.search(str(num),thePost["filename"]) or num == 0 assert type(num) == int or type(num) == long
def test_getPostsList(): for boardName in board.getBoards(): l = boardDIR.getPostsList(boardName) assert boardName and len(l) > 0 for thePost in l: num = thePost["pnum"] assert num >= 0 assert type(num) == int or type(num) == long num = thePost["level"] assert num >= 0 assert type(num) == int or type(num) == long s = thePost["filename"] assert len(s) >= 0 assert re.search(r"^[A-Z]\.[0-9]{8,11}\.[A-Z]$", s) assert type(s) == str s = thePost["title"] assert len(s) >= 0 assert type(s) == str num = thePost["reid"] assert num >= 10**9 or num == 0 assert num <= 10**9 * 2 assert type(num) == int or type(num) == long s = thePost["owner"] assert len(s) >= 0 assert re.search(r"^[a-zA-Z0-9\.]{2,14}$", s) assert type(s) == str s = thePost["accessed"] assert len(s) >= 0 assert type(s) == str num = thePost["id"] assert num >= 10**9 or num == 0 assert num <= 10**9 * 2 assert re.search(str(num), thePost["filename"]) or num == 0 assert type(num) == int or type(num) == long
def test_getBoards(): boards = board.getBoards() for boardname in boards: assert re.search(r"^[a-zA-Z0-9]{2,12}$",boardname)