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")
Exemple #2
0
    # 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 !!!")
            print("Vous pouvez supprimer les messages ?")
            phpbb.delete_post_list(post_list)
    else:
        print('> Login failed')
    phpbb.logout()
    phpbb.close()
except KeyboardInterrupt:
    print("\nAu revoir")
    sys.exit(0)
def test_login():
    """Test PhpBB login()."""
    forum = PhpBB(host)
    assert forum.login(username, password)
    forum.logout()