def test_is_live(user_factory, project_factory): user = user_factory() admin = user_factory(is_superuser=True) project1 = project_factory(is_draft=False) project2 = project_factory(is_draft=True) assert predicates.is_live(user, project1) assert not predicates.is_live(user, project2) assert not predicates.is_live(user, False) assert predicates.is_live(admin, project1) assert not predicates.is_live(admin, project2) assert not predicates.is_live(admin, False)
def is_live_context(user, item): if item: return is_live(user, item.project) return False