def delete_user(self):
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     all_users_page.check_nth_user(2)
     all_users_page.select_delete_action(confirm=True)
     message = all_users_page.get_message()
     self.assertEqual(message, SUCCESSFULLY_DELETED_USER_MSG)
Ejemplo n.º 2
0
 def delete_user(self, username):
     self.global_navigation.sign_out()
     login(self.driver, VALID_CREDENTIALS)
     self.driver.go_to(ALL_USERS_URL)
     all_users_page = AllUsersPage(self.driver)
     self.driver.find(by_xpath("//td[contains(.,'%s')]/../td/input" % username)).click()
     all_users_page.select_delete_action(confirm=True)
     self.driver.wait_for_element(UI_TEST_TIMEOUT, by_css("span.loading"), True)
     self.driver.wait_until_modal_dismissed()
     message = all_users_page.get_message()
     self.assertEqual(message, SUCCESSFULLY_DELETED_USER_MSG)
Ejemplo n.º 3
0
class TestAllUsers(HeadlessRunnerTest):

    def setUp(self):
        self.global_navigation = login(self.driver, VALID_CREDENTIALS)
        self.driver.go_to(ALL_USERS_URL)
        self.all_users_page = AllUsersPage(self.driver)

    def tearDown(self):
        self.global_navigation.sign_out()

    @attr('functional_test')
    def test_should_not_show_delete_if_any_users_selected(self):
        self.all_users_page.click_check_all_users(check=False)
        self.all_users_page.click_action_button()
        self.assertFalse(self.all_users_page.actions_menu_shown())

    @attr('functional_test')
    def test_should_not_delete_super_admin_user(self):
        self.all_users_page.click_check_all_users()
        self.all_users_page.select_delete_action(confirm=True)
        message = self.all_users_page.get_message()
        self.assertEqual(message, ADMIN_CANT_BE_DELETED)

    @attr('functional_test')
    def test_should_create_activity_log_and_submit_data(self):
        add_user_page = self.all_users_page.navigate_to_add_user()
        add_user_page.add_user_with(NEW_USER_DATA)
        self.driver.go_to(LOGOUT)
        new_user_credential = {USERNAME: NEW_USER_DATA[USERNAME], PASSWORD: "******"}
        login(self.driver, new_user_credential)
        self.driver.go_to(DATA_WINNER_ALL_PROJECTS_PAGE)
        project_name, questionnaire_code = self.create_project()
        self.send_submission(questionnaire_code)
        self.delete_user(NEW_USER_DATA[USERNAME])
        self.check_sent_submission(project_name)
        self.check_deleted_user_name_on_activity_log_page(project_name)
        self.driver.go_to(LOGOUT)
        login(self.driver, VALID_CREDENTIALS)

    @attr('functional_test')
    def test_should_update_user_name_when_edited_from_datasender_page(self):
        add_user_page = self.all_users_page.navigate_to_add_user()
        add_user_page.add_user_with(EDIT_USER_DATA)
        self.driver.go_to(DATA_WINNER_ALL_DATA_SENDERS_PAGE)
        all_datasenders_page = AllDataSendersPage(self.driver)
        all_datasenders_page.search_with(EDIT_USER_DATA.get('username'))
        self.driver.find(all_datasenders_page.get_checkbox_selector_for_datasender_row(1)).click()
        all_datasenders_page.select_edit_action()
        EDIT_DETAILS = {"name": "New testUser",
                        "mobile_number": EDIT_USER_DATA.get("mobile_phone"),
                        "commune": "Madagascar",
                        "gps": "-21.7622088847 48.0690991394"}
        AddDataSenderPage(self.driver).enter_data_sender_details_from(EDIT_DETAILS).navigate_to_datasender_page()
        self.driver.go_to(ALL_USERS_URL)
        self.all_users_page = AllUsersPage(self.driver)
        element = self.driver.find(by_xpath(NAME_COLUMN % EDIT_USER_DATA.get("username")))
        self.assertEquals(EDIT_DETAILS.get("name"),element.text)

    def send_submission(self, questionnaire_code):
        client = Client()
        valid_sms = {"from_msisdn": NEW_USER_DATA[MOBILE_PHONE],
                     "to_msisdn": '919880734937',
                     MESSAGE: "%s 10.10.2010" % questionnaire_code,
                     "message_id": uuid.uuid1().hex}
        resp = client.post('/submission',valid_sms)
        self.assertIn("Thank you", resp.content)

    def create_project(self):
        dashboard_page = DashboardPage(self.driver)
        create_project_page = dashboard_page.navigate_to_create_project_page()
        create_project_page = create_project_page.select_blank_questionnaire_creation_option()
        create_project_page.create_questionnaire_with(VALID_SUMMARY_REPORT_DATA, QUESTIONNAIRE_DATA)
        overview_page = create_project_page.save_and_create_project_successfully()
        questionnaire_code = overview_page.get_questionnaire_code()
        project_name = overview_page.get_project_title()
        return project_name, questionnaire_code

    def delete_user(self, username):
        self.driver.go_to(LOGOUT)
        login(self.driver, VALID_CREDENTIALS)
        self.driver.go_to(ALL_USERS_URL)
        all_users_page = AllUsersPage(self.driver)
        self.driver.find(by_xpath("//td[contains(.,'%s')]/../td/input" % username)).click()
        all_users_page.select_delete_action(confirm=True)
        self.driver.wait_for_element(UI_TEST_TIMEOUT, by_css("span.loading"), True)
        self.driver.wait_until_modal_dismissed()
        message = all_users_page.get_message()
        self.assertEqual(message, SUCCESSFULLY_DELETED_USER_MSG)

    def check_sent_submission(self, project_name):
        all_data_page = self.global_navigation.navigate_to_all_data_page()
        data_analysis_page = all_data_page.navigate_to_data_analysis_page(project_name)
        data_sender_name = data_analysis_page.get_all_data_on_nth_row(1)[1]
        self.assertTrue("kimi" in data_sender_name)

    def check_deleted_user_name_on_activity_log_page(self, project_name):
        self.driver.go_to(DATA_WINNER_USER_ACTIVITY_LOG_PAGE)
        username = self.driver.find(by_xpath("//td[contains(.,'%s')]/../td[1]" % project_name)).text
        action = self.driver.find(by_xpath("//td[contains(.,'%s')]/../td[2]" % project_name)).text
        self.assertEqual("Deleted User", username)
        self.assertEqual("Created Questionnaire", action)