def test_visitor_does_not_see_admin_panel_navigation(web_server: str, browser: DriverAPI, dbsession: Session): """Admin actions are shown to logged in visitors only.""" browser.visit(web_server + "/blog/") assert not browser.is_text_present("Admin actions")
def test_visitor_sees_only_relevant_posts_in_tag_roll(web_server: str, browser: DriverAPI, dbsession: Session, fakefactory): """Visitors should not see unpublished posts in blog roll.""" with transaction.manager: tag = fakefactory.TagFactory() post = fakefactory.PostFactory(public=True, tags=[tag]) fakefactory.PostFactory() dbsession.expunge_all() browser.visit(web_server + "/blog/tag/{}".format(tag)) assert len(browser.find_by_css("div.post")) == 1 assert browser.is_text_present(post.title)
def test_user_see_admin_panel_navigation(web_server: str, browser: DriverAPI, dbsession: Session, fakefactory, login_user): """Logged in user sees navigation link to admin panel on blog-roll.""" with transaction.manager: user = fakefactory.UserFactory(admin=True) dbsession.expunge_all() login_user(user) browser.visit(web_server + "/blog/") # admin action menu is present assert browser.is_text_present("Admin actions") # after clicking on "Manage posts" user is redirected to posts-listing on admin panel browser.find_by_xpath('//a[text()[contains(.,"Manage posts")]]').click() assert browser.url.endswith('/admin/models/blog-posts/listing')