<s> import datetime <EOL> from random import randrange <EOL> import pytest <EOL> from pages . desktop . questions_page import AskNewQuestionsPage , QuestionsPage <EOL> class TestQuestions : <EOL> @ pytest . mark . native <EOL> def test_that_posting_question_works ( self , base_url , selenium , variables ) : <EOL> """<STR_LIT>""" <EOL> user = variables [ '<STR_LIT>' ] [ '<STR_LIT:default>' ] <EOL> timestamp = datetime . datetime . today ( ) <EOL> q_to_ask = "<STR_LIT>" % ( timestamp ) <EOL> q_details = "<STR_LIT>" % ( timestamp ) <EOL> ask_new_questions_page = AskNewQuestionsPage ( base_url , selenium ) . open ( ) <EOL> ask_new_questions_page . sign_in ( user [ '<STR_LIT:username>' ] , user [ '<STR_LIT:password>' ] ) <EOL> ask_new_questions_page . click_firefox_product_link ( ) <EOL> ask_new_questions_page . click_category_problem_link ( ) <EOL> ask_new_questions_page . type_question ( q_to_ask ) <EOL> ask_new_questions_page . close_stage_site_banner ( ) <EOL> ask_new_questions_page . click_none_of_these_solve_my_problem_button ( ) <EOL> view_question_pg = ask_new_questions_page . fill_up_questions_form ( q_to_ask , q_details ) <EOL> assert q_to_ask == view_question_pg . question <EOL> assert q_details == view_question_pg . question_detail <EOL> @ pytest . mark . nondestructive <EOL> def test_that_questions_sorts_correctly_by_filter_equal_to_solved ( self , base_url , selenium ) : <EOL> """<STR_LIT>""" <EOL> expected_sorted_text = "<STR_LIT>" <EOL> questions_page = QuestionsPage ( base_url , selenium ) . open ( ) <EOL> questions_page . click_all_products ( ) <EOL> questions_page . click_questions_done_tab ( ) <EOL> questions_page . click_sort_by_solved_questions ( ) <EOL> if not questions_page . are_questions_present : <EOL> pytest . skip ( "<STR_LIT>" % expected_sorted_text ) <EOL> for question in questions_page . questions : <EOL> assert '<STR_LIT>' in question . solved_questions_filter <EOL> @ pytest . mark . nondestructive <EOL> def test_questions_sorts_correctly_by_filter_equal_to_unanswered ( self , base_url , selenium ) : <EOL> """<STR_LIT>""" <EOL> expected_sorted_text = "<STR_LIT>" <EOL> questions_page = QuestionsPage ( base_url , selenium ) . open ( ) <EOL> questions_page . click_all_products ( ) <EOL> questions_page . click_all_questions_tab ( ) <EOL> questions_page . click_sort_by_unanswered_questions ( ) <EOL> if not questions_page . are_questions_present : <EOL> pytest . skip ( "<STR_LIT>" % expected_sorted_text ) <EOL> for question in questions_page . questions : <EOL> assert <NUM_LIT:0> == question . number_of_replies <EOL> def test_that_questions_problem_count_increments ( self , base_url , selenium ) : <EOL> """<STR_LIT>""" <EOL> questions_page = QuestionsPage ( base_url , selenium ) . open ( ) <EOL> questions_page . click_all_products ( ) <EOL> view_question_page = questions_page . click_any_question ( <NUM_LIT:1> ) <EOL> initial_count = view_question_page . problem_count <EOL> view_question_page . click_problem_too_button ( ) <EOL> view_question_page . refresh ( ) <EOL> post_click_count = view_question_page . problem_count <EOL> assert initial_count + <NUM_LIT:1> == post_click_count <EOL> def test_contributor_flow_to_support_forum_post ( self , base_url , selenium , variables ) : <EOL> """<STR_LIT>""" <EOL> user = variables [ '<STR_LIT>' ] [ '<STR_LIT:default>' ] <EOL> questions_page = QuestionsPage ( base_url , selenium ) . open ( ) <EOL> questions_page . sign_in ( user [ '<STR_LIT:username>' ] , user [ '<STR_LIT:password>' ] ) <EOL> questions_page . click_all_products ( ) <EOL> assert questions_page . questions_count > <NUM_LIT:0> , '<STR_LIT>' <EOL> question = questions_page . questions [ randrange ( questions_page . questions_count ) ] <EOL> forum_page = question . click_question_link ( ) <EOL> reply = "<STR_LIT>" <EOL> forum_page . post_reply ( reply ) <EOL> assert forum_page . is_reply_text_present ( user [ '<STR_LIT:username>' ] , reply ) , u'<STR_LIT>' % ( <EOL> reply , user [ '<STR_LIT:username>' ] ) </s>
