import time
from fb_common import session_facebook
d = session_facebook()
# test 1 : /saved/ (page connectee-only)
d.get("https://www.facebook.com/saved/"); time.sleep(5)
u1 = d.current_url
saved_ok = ("index.php" not in u1) and ("login" not in u1.lower())
cks = {c["name"]:1 for c in d.get_cookies()}
print("TEST /saved/ -> URL:", u1[:90])
print("  index.php (login bounce):", "index.php" in u1, "| c_user:", "c_user" in cks, "| OK:", saved_ok)
# test 2 : la page cible
d.get("https://www.facebook.com/collectif.de.citoyens.ucclois"); time.sleep(6)
h = d.page_source
wall = ("Connexion ou inscription" in h) or ('name="email"' in h)
print("TEST page Collectif -> login wall:", wall, "| len html:", len(h))
print("RESULTAT GLOBAL:", "CONNECTE" if (saved_ok and not wall) else "NON CONNECTE")
d.quit()
