def loggedin_forum(self): """Connect to forum before testing, disconnect after.""" # Setup : log in forum forum = PhpBB(host) forum.login(username, password) print("Pytest fixture : Logging in forum") yield forum # this is where the testing happens # Teardown : log out forum forum.logout() print("Pytest fixture : Logging out forum")
Topic = namedtuple('Topic', ['f', 't', 'desc']) topic_list = [ Topic(147, 15066, 'équipe_DC_Hors'), Topic(147, 7848, 'équipe_DC'), Topic(12, 14511, 'absences'), Topic(121, 13388, 'news_média'), Topic(119, 13387, "News Comics"), ] try: # user = int(sys.argv[2]) cfg = Settings(CFG_FILE) cfg_dict = cfg.read_section(CFG_FORUM) phpbb = PhpBB(cfg_dict['host']) # forum.setUserAgent(cfg.user_agent) if phpbb.login(cfg_dict['username'], cfg_dict['password']): print('Login') for top in topic_list: topic = f'viewtopic.php?f={top.f}&t={top.t}' post_list = phpbb.get_topic_posts(topic, int( cfg_dict['max_count'])) # noqa: E501 n = len(post_list) print(f"{n} posts dans ce topic") print("===================") post_list = PostList([p for p in post_list[1:] if p.old > 365]) print("===================") post_list.print_posts() print("===================") print("TOUS LES MESSAGES précédents seront SUPPRIMÉS !!!")
new_mess = replace_message(origin) return mess, new_mess if __name__ == '__main__': old_file = open("old.txt", "w") new_file = open("new.txt", "w") # Config cfg = Settings(cfg_file) if cfg.load(cfg_forum, Const.cfg_opts): phpbb = PhpBB(cfg.host) max = int(cfg.max_count) if phpbb.login(cfg.username, cfg.password): print('Login') mode = 0 while True: mode = input('Que voulez-vous faire ?\n' '1- Traiter un seul topic\n' '2- Traiter un sous forum entier ' '(DC Rebirth / Marvel / etc...)\n' 'Réponse : 1 ou 2\n') if 1 <= int(mode) <= 2: break else: print("\nValeur incorrect") if int(mode) == 1:
def test_login(): """Test PhpBB login().""" forum = PhpBB(host) assert forum.login(username, password) forum.logout()
except sqlite3.OperationalError: # Table already exists table = db[DB_TABLE] # Log logfile = open(".merci_logfile.txt", "a+") logfile.write(str(datetime.datetime.now()) + "\n") # Config cfg = Settings(CFG_FILE) cfg_dict = cfg.read_section(CFG_FORUM) forum_dict = cfg.read_section("forums") phpbb = PhpBB(cfg_dict["host"]) regex1, regex2, regex3 = tools.compute_regex(cfg) if phpbb.login(cfg_dict["username"], cfg_dict["password"]): print("Login") mode = 0 while True: mode = int(input(Const.MODE_CHOICE)) if 1 <= mode <= 4: break else: print("\nValeur incorrect") # One topic if mode == 1: f_id = int(input(Const.F_INPUT)) topic_id = int(input(Const.T_INPUT)) try: