def test_find_user_token_error(tmpdir): path_db = str(tmpdir.join("test.sqlite3")) con = database.ConnectDatabase(path_db) user_data = admin_tools.UserDB() name = "Lilly" out = user_data.find_user_token(con, name) assert "An error has occured:" in out
def test_insert_user_error(tmpdir): path_db = str(tmpdir.join("test.sqlite3")) con = database.ConnectDatabase(path_db) user_data = admin_tools.UserDB() acc_not_exist = ["Susi", 2] out_not = user_data.insert_user(acc_not_exist, con) assert "An error has occured:" in out_not
def test_delete_ip(demo_db_path): con = database.ConnectDatabase(demo_db_path) out_origin = con.parse_statement("SELECT * FROM ip", ()) ud = admin_tools.UserDB() out = ud.delete_ip(con, "1") out_less = con.parse_statement("SELECT * FROM ip", ()) assert "call -pi to see the changes" in out assert len(out_origin) > len(out_less)
def test_print_ip(demo_db_path, capsys): conn = database.ConnectDatabase(demo_db_path) ud = admin_tools.UserDB() out_return = ud.print_ip(conn) out = capsys.readouterr() assert out_return == "" assert "TABLE ip:" in out[0] assert "(2, 1, '192.0.2.41')" in out[0]
def test_print_db_user(demo_db_path, capsys): conn = database.ConnectDatabase(demo_db_path) ud = admin_tools.UserDB() out_return = ud.print_db_user(conn) out = capsys.readouterr() assert out_return == "" assert "TABLE login:"******"(2, 'Lilly', 'lil', 1)" in out[0]
def test_find_user_token(demo_db_path, capsys): con = database.ConnectDatabase(demo_db_path) user_data = admin_tools.UserDB() name = "Lilly" out = user_data.find_user_token(con, name) out_print = capsys.readouterr() assert out == "lil" assert "Token:" in out_print[0]
def test_insert_user(demo_db_path): con = database.ConnectDatabase(demo_db_path) user_data = admin_tools.UserDB() acc_not_exist = ["Susi", 2] acc_exist = ["Lilly", 1] out_not = user_data.insert_user(acc_not_exist, con) out_exist = user_data.insert_user(acc_exist, con) assert out_not is True assert "Username already exists" in out_exist
def test_create_tables_user(tmpdir): path_db = str(tmpdir.join("test.sqlite3")) con = database.ConnectDatabase(path_db) user_data = admin_tools.UserDB() out = user_data.create_tables_user(con) out_ip = con.parse_statement("SELECT * FROM ip", ()) out_login = con.parse_statement("SELECT * FROM login", ()) assert out is True assert out_ip == [] assert out_login == []
def test_delete_ip_error(tmpdir): path_db = str(tmpdir.join("test.sqlite3")) con = database.ConnectDatabase(path_db) ud = admin_tools.UserDB() out = ud.delete_ip(con, "1") assert "An error has occured:" in out
def test_print_db_user_error(tmpdir): path_db = str(tmpdir.join("test.sqlite3")) conn = database.ConnectDatabase(path_db) ud = admin_tools.UserDB() out = ud.print_db_user(conn) assert "An error has occured:" in out