def setup(request): global customer config = getattr(request, '_funcargs')['config'] customer = random_user(UserRoles.CUSTOMER) db_user = GkrDbSteps(config) db_user.create_user(customer) db_user.blocks_user(customer.customers_data.mobile_phone, is_blocked=1)
def test_operator_queue_successful(self, config, teardown): operator = random_user(UserRoles.OPERATOR) user = GkrUserSteps(config) db_user = GkrDbSteps(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) db_user.create_user(operator) global queue_operator_mobile queue_operator_mobile = operator.customers_data.mobile_phone day = (datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d') print_day = (datetime.now() + timedelta(days=1)).strftime('%d.%m.%Y') locality = 'с. Александровка' street = 'ул. Виноградная' house = rand_num(2) flat = rand_num(2) user.login(operator.customers_data.mobile_phone, operator.password) user.should_see_element(queue_page) customer = user.fill_random_operator_queue() global queue_customer_by_operator_mobile queue_customer_by_operator_mobile = customer.mobile_phone user.chooses_from_select(queue_page.SERVICE, Services.DEAL_REGISTER.name) user.chooses_from_select(queue_page.OBJECT_TYPE, ObjectTypes.STROI_OBJECT.name) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, house) user.enters_text(queue_page.FLAT, flat) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) time = queue_page.CALENDAR.time_list[0].text user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) user.should_see_element_with_text(ticket_data_dialog.TICKET_TIME, (print_day + ' ' + time)) user.should_see_element_with_text(ticket_data_dialog.TICKET_SERVICE, Services.DEAL_REGISTER.name) user.should_see_element_with_text(ticket_data_dialog.TICKET_DEP, Departments.BEL_DEP.name) user.should_see_element_with_text( ticket_data_dialog.TICKET_CUSTOMER, customer.surname + " " + customer.name + " " + customer.patronymic) user.should_see_element_with_text( ticket_data_dialog.TICKET_ADDRESS, Departments.BEL_DEP.short_name + " " + locality + " " + street + " д. " + house + " кв. " + flat) db_user.should_see_service_group_id( ticket_data_dialog.TICKET_NUMBER.element.text, UserTypes.CUSTOMER.id)
def setup(request): config = getattr(request, '_funcargs')['config'] global customer, db_user, user, customer_edit_page customer = random_user(UserRoles.CUSTOMER) db_user = GkrDbSteps(config) user = GkrUserSteps(config) customer_edit_page = CustomerEditPage(config) db_user.create_user(customer)
def setup(request): global operator, customer, db_user config = getattr(request, '_funcargs')['config'] db_user = GkrDbSteps(config) user = GkrUserSteps(config) user.login(ADMIN.login, ADMIN.password) user.waits_for_ajax() user.opens(Urls.ADMIN_STATISTIC.url) operator = random_user(UserRoles.OPERATOR) customer = random_user(UserRoles.CUSTOMER, is_legal=True) db_user.create_user(operator) db_user.create_user(customer)
def config(request): c.config(request) for k, v in request.config.option.__dict__.items(): setattr(tc, k, v) db_user = GkrDbSteps(tc) db_user.create_user(CUSTOMER) db_user.create_user(OPERATOR) db_user.create_user(LEGAL) db_user.create_user(ADMIN) tc.driver.set_window_size(1280, 900) yield tc tc.driver.quit()
def setup(request): global fields_operator config = getattr(request, '_funcargs')['config'] db_user = GkrDbSteps(config) queue_page = QueuePage(config) fields_operator = random_user(UserRoles.OPERATOR) db_user.create_user(fields_operator) user = GkrUserSteps(config) user.login(fields_operator.customers_data.mobile_phone, fields_operator.password) user.waits_for_element_displayed(queue_page)
def setup(request): global db_user, session, login_url, logout_url, blocking_url, ticket_edit_url, customer config = getattr(request, '_funcargs')['config'] db_user = GkrDbSteps(config) session = HttpSteps.HttpSession() logout_url = config.base_url + Urls.LOGOUT.url blocking_url = config.base_url + Urls.ADMIN_BLOCKING.url login_url = config.base_url + Urls.LOGIN.url + '/ajax' ticket_edit_url = config.base_url + Urls.ADMIN_TICKED_EDIT.url r_user = random_user(UserRoles.CUSTOMER) db_user.create_user(r_user) sleep(1) customer = db_user.query_first( Customers, Customers.mobile_phone == r_user.customers_data.mobile_phone)
def test_legal_timeslot(self, config): user = GkrUserSteps(config) db_user = GkrDbSteps(config) queue_page = QueuePage(config) profile_page = ProfilePage(config) ticket_data_dialog = TicketDataDialog(config) for i in legal_timeslot_data: legal = random_user(UserRoles.CUSTOMER, is_legal=True) db_user.create_user(legal) day = (datetime.now() + timedelta(days=random.randrange(0, 2))).strftime('%Y-%m-%d') service = i[0] stat_value = i[1] locality = 'с. Виноградное' street = 'ул. Горная' user.login(legal.customers_data.mobile_phone, legal.password) user.waits_for_element_displayed(profile_page) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.chooses_from_select(queue_page.SERVICE, service) user.chooses_from_select(queue_page.OBJECT_TYPE, '1') user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, 2) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) user.enters_text(queue_page.CAPTCHA, '11111') user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) user.login(legal.customers_data.mobile_phone, legal.password) user.waits_for_element_displayed(profile_page) user.selects_from_main_menu(MainMenu.QUEUE) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.chooses_from_select(queue_page.SERVICE, service) user.waits_for_ajax() user.should_see_element_with_text(queue_page.STAT_INDICATOR, stat_value) db_user.delete_user_by_mobile(legal.customers_data.mobile_phone)
def test_customers_search(self, config, attribute, setup, teardown): user = GkrUserSteps(config) db_user = GkrDbSteps(config) customers_admin_page = CustomersAdminPage(config) db_user.create_user(customer) user.opens(Urls.ADMIN_CUSTOMERS.url) user.should_see_element(customers_admin_page) user.enters_text(customers_admin_page.TERM_FIELD, "") user.clicks(customers_admin_page.SEARCH_SUBMIT) user.waits_for_ajax() term = getattr(getattr(customer, 'customers_data'), attribute) user.enters_text(customers_admin_page.TERM_FIELD, term) user.clicks(customers_admin_page.SEARCH_SUBMIT) user.waits_for_ajax() user.should_see_list_size(customers_admin_page.TABLE, self.expected_rows) user.should_see_element_contains_text( customers_admin_page.TABLE.elements[self.expected_rows - 1], term)
def test_history_search_empty(self, config, teardown): global advance_one, advance_two, history_operator advance_one = None advance_two = None user = GkrUserSteps(config) db_user = GkrDbSteps(config) main_page = MainPage(config) history_operator = random_user(UserRoles.OPERATOR) db_user.create_user(history_operator) user.login(history_operator.customers_data.mobile_phone, history_operator.password) user.waits_for_element_displayed(main_page.top_menu.LOGOUT) user.selects_from_main_menu(MainMenu.HISTORY) user.should_see_text(ConfirmationMessages.HISTORY_EMPTY) user.reloads_page() user.search_history(randrus_str(7)) user.should_see_text(ConfirmationMessages.HISTORY_EMPTY)
def test_password_recovery(self, config, teardown): user = GkrUserSteps(config) db_user = GkrDbSteps(config) login_page = LoginForm(config) main_page = MainPage(config) profile_page = ProfilePage(config) dialogs = Dialogs(config) db_user.create_user(customer) user.logout() user.clicks(main_page.top_menu.LOGIN_LINK) user.clicks(main_page.login_form.RECOVERY) user.enters_text(main_page.recovery.EMAIL, customer.customers_data.email) user.clicks(main_page.recovery.SUBMIT) user.waits_for_element_disappeared(main_page.recovery.WAIT, config.page_load_timeout) user.should_see_element_with_text( main_page.recovery.SUCCESS_TEXT, ConfirmationMessages.PASSWORD_RECOVERY_SUCCESS) created_c = db_user.query_first( Customers, Customers.mobile_phone == customer.customers_data.mobile_phone) user.opens('/forgot/success/?code=' + created_c.code + '&id=' + str(created_c.id)) user.should_see_element_matched_to( dialogs.RESET_PASSWORD_SUCCESS_DIALOG, contains_string( ConfirmationMessages.PASSWORD_RECOVERY_CONFIRMED.text)) new_password = db_user.query_first( AclUsers, AclUsers.name == customer.customers_data.mobile_phone) user.login(customer.customers_data.mobile_phone, customer.password) user.should_see_element_with_text(login_page.ERROR, ErrorMessages.LOGIN_FAILED) user.login(customer.customers_data.mobile_phone, new_password.pwd) user.should_see_element(profile_page)
def test_operator_timeslot(self, config): user = GkrUserSteps(config) db_user = GkrDbSteps(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) day = (datetime.now() + timedelta(days=random.randrange(0, 2))).strftime('%Y-%m-%d') locality = 'с. Виноградное' street = 'ул. Горная' house = 1 for i in operator_timeslot_data: operator = random_user(UserRoles.OPERATOR) db_user.create_user(operator) object_type = i[0] stat_value = i[1] user.login(operator.customers_data.mobile_phone, operator.password) user.should_see_element(queue_page) user.fill_random_operator_queue() user.chooses_from_select(queue_page.SERVICE, Services.DEAL_REGISTER.name) user.chooses_from_select(queue_page.OBJECT_TYPE, object_type) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, house) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) user.opens(Urls.REGISTRATOR) user.chooses_from_select(queue_page.CITY, Departments.FEO_DEP.short_name) user.waits_for_ajax() user.should_see_element_with_text(queue_page.STAT_INDICATOR, stat_value) db_user.delete_user_by_mobile(operator.customers_data.mobile_phone)
def test_history_search_by_fio(self, config, teardown): global advance_one, advance_two, history_operator user = GkrUserSteps(config) db_user = GkrDbSteps(config) history_page = HistoryPage(config) history_operator = random_user(UserRoles.OPERATOR) db_user.create_user(history_operator) advance_one = db_user.fill_advance_queue( Departments.BEL_DEP, Services.SINGLE_WINDOW, datetime.now() - timedelta(days=1), ObjectTypes.STROI_OBJECT, history_operator) advance_two = db_user.fill_advance_queue( Departments.BEL_DEP, Services.GKN, datetime.now() - timedelta(days=2), ObjectTypes.DOMOVLADENIE, history_operator) user.login(history_operator.customers_data.mobile_phone, history_operator.password) user.waits_for_element_displayed(history_page.top_menu.LOGOUT) user.selects_from_main_menu(MainMenu.HISTORY) # поиск по имени user.search_history(advance_two.input_data.split()[2]) user.should_see_list_size(history_page.SEARCH_ROWS, 1) user.should_matches_to_list_item(history_page.SEARCH_ROWS, contains_string(str(advance_two.id))) # поиск по фамилии user.search_history(advance_one.input_data.split()[1]) user.should_see_list_size(history_page.SEARCH_ROWS, 1) user.should_matches_to_list_item(history_page.SEARCH_ROWS, contains_string(str(advance_one.id))) # поиск по отчеству user.search_history(advance_two.input_data.split()[3]) user.should_see_list_size(history_page.SEARCH_ROWS, 1) user.should_matches_to_list_item(history_page.SEARCH_ROWS, contains_string(str(advance_two.id)))
def test_password_change_successfully(self, config, teardown): user = GkrUserSteps(config) db_user = GkrDbSteps(config) profile_page = ProfilePage(config) customer = random_user(UserRoles.CUSTOMER) db_user.create_user(customer) global mobile mobile = customer.customers_data.mobile_phone password = '******' user.login(customer.customers_data.mobile_phone, customer.password) user.waits_for_element_displayed(profile_page) user.enters_text(profile_page.PASSWORD, password) user.enters_text(profile_page.PASSWORD_CONFIRM, password) user.clicks(profile_page.SUBMIT) user.waits_for_element_displayed(profile_page.SUCCESS_MESSAGE) user.should_see_element_with_text(profile_page.SUCCESS_MESSAGE, ConfirmationMessages.PROFILE_CHANGED) user.login(customer.customers_data.mobile_phone, password) user.should_see_element(profile_page)
def test_customer_queue_successful(self, config, teardown): customer = random_user(UserRoles.CUSTOMER) user = GkrUserSteps(config) db_user = GkrDbSteps(config) profile_page = ProfilePage(config) queue_page = QueuePage(config) ticket_data_dialog = TicketDataDialog(config) db_user.create_user(customer) global queue_mobile queue_mobile = customer.customers_data.mobile_phone day = (datetime.now() + timedelta(days=1)).strftime('%Y-%m-%d') print_day = (datetime.now() + timedelta(days=1)).strftime('%d.%m.%Y') locality = 'с. Александровка' street = 'ул. Виноградная' house = rand_num(2) + '/1a' flat = rand_num(2) + 'б' user.login(customer.customers_data.mobile_phone, customer.password) user.should_see_element(profile_page) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.chooses_from_select(queue_page.SERVICE, Services.SINGLE_WINDOW.name) user.chooses_from_select(queue_page.OBJECT_TYPE, ObjectTypes.DOMOVLADENIE.name) user.chooses_from_select(queue_page.CITY, Departments.BEL_DEP.short_name) user.enters_suggest(queue_page.LOCALITY, locality) user.enters_suggest(queue_page.STREET, street) user.enters_text(queue_page.HOUSE, house) user.enters_text(queue_page.FLAT, flat) user.enters_text(queue_page.CAPTCHA, '11111') user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(queue_page.CALENDAR) user.set_calendar_date(queue_page.CALENDAR, day) user.set_calendar_time(queue_page.CALENDAR, None) time = queue_page.CALENDAR.time_list[0].text user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed(ticket_data_dialog) ticket_id = ticket_data_dialog.TICKET_NUMBER.element.text user.should_see_element_with_text(ticket_data_dialog.TICKET_TIME, (print_day + ' ' + time)) user.should_see_element_with_text(ticket_data_dialog.TICKET_SERVICE, Services.SINGLE_WINDOW.name) user.should_see_element_with_text(ticket_data_dialog.TICKET_DEP, Departments.BEL_DEP.name) user.should_see_element_with_text( ticket_data_dialog.TICKET_CUSTOMER, customer.customers_data.surname + " " + customer.customers_data.name + " " + customer.customers_data.patronymic) user.should_see_element_with_text( ticket_data_dialog.TICKET_ADDRESS, Departments.BEL_DEP.short_name + " " + locality + " " + street + " д. " + house + " кв. " + flat) db_user.should_see_service_group_id(ticket_id, UserTypes.CUSTOMER.id) user.close(ticket_data_dialog) user.selects_from_main_menu(MainMenu.QUEUE) user.waits_for_element_displayed(queue_page) user.clicks(queue_page.SUBMIT) user.waits_for_element_displayed = user.waits_for_element_displayed( queue_page.ERROR_TEXT) user.should_see_text_in_list( queue_page.ERROR_TEXT, ErrorMessages.CUSTOMER_REGISTRATION_LIMIT.text % (customer.customers_data.serial, customer.customers_data.no, ticket_id)) user.opens(Urls.PROFILE) history_item = profile_page.TICKETS_HISTORY.get_history_by_id( ticket_id) user.should_see_history_services(history_item, ticket_id, Services.SINGLE_WINDOW.name, print_day + ' ' + time)