コード例 #1
0
    def tearDown(self):
        import sys

        exception_info = sys.exc_info()
        if exception_info != (None, None, None):
            import os

            if not os.path.exists("screenshots"):
                os.mkdir("screenshots")
            self.driver.get_screenshot_as_file(
                "screenshots/screenshot-%s-%s.png" %
                (self.__class__.__name__, self._testMethodName))

        try:
            if self.email is not None:
                email = self.email
                dbmanager = DatabaseManager()
                dbname = dbmanager.delete_organization_all_details(
                    email.lower())
                couchwrapper = CouchHttpWrapper()
                couchwrapper.deleteDb(dbname)
        except TypeError as e:
            pass

        teardown_driver(self.driver)
コード例 #2
0
 def tearDownClass(cls):
     if cls.email is not None:
         dbmanager = DatabaseManager()
         dbname = dbmanager.delete_organization_all_details(cls.email.lower())
         couchwrapper = CouchHttpWrapper()
         couchwrapper.deleteDb(dbname)
     teardown_driver(cls.driver)
コード例 #3
0
 def prepare_data_for_showing_only_logs_for_current_organization(self):
     confirmation_page, email = register_and_get_email(self.driver)
     account_activate_page = ActivateAccountPage(self.driver)
     dbmanager = DatabaseManager()
     activation_code = dbmanager.get_activation_code(email.lower())
     account_activate_page.activate_account(activation_code)
     self.login(credential={USERNAME: email, PASSWORD: "******"})
コード例 #4
0
 def test_register_trial_organization(self):
     registration_confirmation_page, email = register_and_get_email_for_trial(
         self.driver)
     self.assertEqual(
         registration_confirmation_page.registration_success_message(),
         REGISTRATION_SUCCESS_MESSAGE)
     dbmanager = DatabaseManager()
     dbmanager.delete_organization_all_details(email)
コード例 #5
0
 def tearDown(self):
     if self.email is not None:
         dbmanager = DatabaseManager()
         dbname = dbmanager.delete_organization_all_details(
             self.email.lower())
         couchwrapper = CouchHttpWrapper("localhost")
         couchwrapper.deleteDb(dbname)
     super(TestActivateAccount, self).tearDown()
コード例 #6
0
 def tearDown(self):
     try:
         self.driver.quit()
         email = self.email
         dbmanager = DatabaseManager()
         dbname = dbmanager.delete_organization_all_details(email)
         couchwrapper = CouchHttpWrapper("localhost")
         couchwrapper.deleteDb(dbname)
     except TypeError as e:
         pass
コード例 #7
0
 def tearDown(self):
     try:
         self.driver.quit()
         email = self.email
         dbmanager = DatabaseManager()
         dbname = dbmanager.delete_organization_all_details(email)
         couchwrapper = CouchHttpWrapper("localhost")
         couchwrapper.deleteDb(dbname)
     except TypeError as e:
         pass
コード例 #8
0
 def test_successful_activation_of_account(self):
     """
     Function to test the successful activation of account with given details
     """
     email = self.prerequisites_of_activate_account()
     account_activate_page = ActivateAccountPage(self.driver)
     dbmanager = DatabaseManager()
     activation_code = dbmanager.get_activation_code(email)
     account_activate_page.activate_account(activation_code)
     self.assertRegexpMatches(account_activate_page.get_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS)))
コード例 #9
0
    def test_login_with_expired_trial_account(self):
        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        dbmanager = DatabaseManager()
        dbmanager.update_active_date_to_expired(
            EXPIRED_TRIAL_ACCOUNT[USERNAME], 365)
        login_page = LoginPage(self.driver)
        time.sleep(2)
        login_page.login_with(EXPIRED_TRIAL_ACCOUNT)

        self.assertEqual(login_page.get_error_message(),
                         fetch_(ERROR_MESSAGE, from_(EXPIRED_TRIAL_ACCOUNT)))
コード例 #10
0
 def tearDown(self):
     teardown_driver(self.driver)
     try:
         for email in self.emails:
             dbmanager = DatabaseManager()
             dbname = dbmanager.delete_organization_all_details(email)
             couchwrapper = CouchHttpWrapper()
             couchwrapper.deleteDb(dbname)
         pass
     except TypeError as e:
         pass
コード例 #11
0
 def test_successful_activation_of_account(self):
     """
     Function to test the successful activation of account with given details
     """
     email = self.prerequisites_of_activate_account()
     account_activate_page = ActivateAccountPage(self.driver)
     dbmanager = DatabaseManager()
     activation_code = dbmanager.get_activation_code(email)
     account_activate_page.activate_account(activation_code)
     self.assertRegexpMatches(
         account_activate_page.get_message(),
         fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS)))
コード例 #12
0
ファイル: login_tests.py プロジェクト: mrudtf/datawinners
    def test_login_with_expired_trial_account(self):
        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        dbmanager = DatabaseManager()
        dbmanager.update_active_date_to_expired(
            EXPIRED_TRIAL_ACCOUNT[USERNAME], 31)
        login_page = LoginPage(self.driver)
        login_page.login_with(EXPIRED_TRIAL_ACCOUNT)
        expired_trail_account_page = ExpiredTrialPage(self.driver)
        self.assertEqual(expired_trail_account_page.get_error_message(),
                         fetch_(ERROR_MESSAGE, from_(EXPIRED_TRIAL_ACCOUNT)))

        subscribe_button = expired_trail_account_page.get_subscribe_button()
        self.assertEqual("Subscribe Now", subscribe_button[0].text)
コード例 #13
0
    def setUp(self):
        super(TestActivateAccount, self).setUp()
        registration_confirmation_page, self.email = register_and_get_email(
            self.driver)
        self.assertEquals(
            registration_confirmation_page.registration_success_message(),
            REGISTRATION_SUCCESS_MESSAGE)

        self.account_activate_page = ActivateAccountPage(self.driver)
        self.dbmanager = DatabaseManager()
        self.activation_code = self.dbmanager.get_activation_code(
            self.email.lower())
        self.account_activate_page.activate_account(self.activation_code)
コード例 #14
0
    def test_should_show_default_datasender_for_newly_created_datasender(self):
        registration_confirmation_page, self.email = register_and_get_email(self.driver)
        assert REGISTRATION_SUCCESS_MESSAGE == registration_confirmation_page.registration_success_message()
        self.account_activate_page = ActivateAccountPage(self.driver)
        self.postgres_dbmanager = DatabaseManager()
        self.activation_code = self.postgres_dbmanager.get_activation_code(self.email.lower())
        self.account_activate_page.activate_account(self.activation_code)

        
        self.page = AllDataSendersPage(self.driver)
        self.page.load()
        
        all_ds_page = self.page
        self.assertEqual(1, all_ds_page.get_datasenders_count())
コード例 #15
0
 def setUpClass(cls):
     cls.organization = DatabaseManager().get_organization_by_email(fetch_(from_(USERNAME), VALID_CREDENTIALS))
     cls.organization.account_type = "Pro"
     cls.organization.save()
     HeadlessRunnerTest.setUpClass()
     cls.global_navigation = login(cls.driver)
     cls.dbm = get_db_manager('hni_testorg_slx364903')
コード例 #16
0
 def setUpClass(cls):
     cls.driver = setup_driver()
     registration_confirmation_page, cls.email = register_and_get_email(cls.driver)
     assert REGISTRATION_SUCCESS_MESSAGE == registration_confirmation_page.registration_success_message()
     cls.account_activate_page = ActivateAccountPage(cls.driver)
     cls.postgres_dbmanager = DatabaseManager()
     cls.activation_code = cls.postgres_dbmanager.get_activation_code(cls.email.lower())
     cls.account_activate_page.activate_account(cls.activation_code)
コード例 #17
0
 def test_successful_login_with_uppercased_email(self):
     registration_confirmation_page, self.email = register_and_get_email(
         self.driver)
     assert REGISTRATION_SUCCESS_MESSAGE == registration_confirmation_page.registration_success_message(
     )
     self.account_activate_page = ActivateAccountPage(self.driver)
     self.postgres_dbmanager = DatabaseManager()
     self.activation_code = self.postgres_dbmanager.get_activation_code(
         self.email.lower())
     self.account_activate_page.activate_account(self.activation_code)
     self.driver.go_to(LOGOUT)
     self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
     login_page = LoginPage(self.driver)
     dashboard_page = login_page.do_successful_login_with({
         USERNAME:
         self.email.upper(),
         PASSWORD:
         u"ngo001"
     })
     self.assertEqual(dashboard_page.welcome_message(),
                      u"Welcome Mickey Gö!")
コード例 #18
0
class TestActivateAccount(BaseTest):
    def setUp(self):
        super(TestActivateAccount, self).setUp()
        registration_confirmation_page, self.email = register_and_get_email(
            self.driver)
        self.assertEquals(
            registration_confirmation_page.registration_success_message(),
            REGISTRATION_SUCCESS_MESSAGE)

        self.account_activate_page = ActivateAccountPage(self.driver)
        self.dbmanager = DatabaseManager()
        self.activation_code = self.dbmanager.get_activation_code(
            self.email.lower())
        self.account_activate_page.activate_account(self.activation_code)

    def tearDown(self):
        if self.email is not None:
            dbmanager = DatabaseManager()
            dbname = dbmanager.delete_organization_all_details(
                self.email.lower())
            couchwrapper = CouchHttpWrapper("localhost")
            couchwrapper.deleteDb(dbname)
        super(TestActivateAccount, self).tearDown()

    @attr('functional_test', 'smoke')
    def test_successful_activation_of_account(self):

        self.assertRegexpMatches(
            self.account_activate_page.get_message(),
            fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS)))

    @attr('functional_test')
    def test_successful_login_with_uppercased_email(self):
        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        login_page = LoginPage(self.driver)
        dashboard_page = login_page.do_successful_login_with({
            USERNAME:
            self.email.upper(),
            PASSWORD:
            u"ngo001"
        })
        self.assertEqual(dashboard_page.welcome_message(), u"Welcome Mickey!")
コード例 #19
0
class TestAllDatasenderBehaviourInTrialOrg(HeadlessRunnerTest):
    @classmethod
    def setUpClass(cls):
        HeadlessRunnerTest.setUpClass()

    @attr('functional_test')
    def test_should_show_default_datasender_for_newly_created_datasender(self):
        registration_confirmation_page, self.email = register_and_get_email(self.driver)
        assert REGISTRATION_SUCCESS_MESSAGE == registration_confirmation_page.registration_success_message()
        self.account_activate_page = ActivateAccountPage(self.driver)
        self.postgres_dbmanager = DatabaseManager()
        self.activation_code = self.postgres_dbmanager.get_activation_code(self.email.lower())
        self.account_activate_page.activate_account(self.activation_code)

        
        self.page = AllDataSendersPage(self.driver)
        self.page.load()
        
        all_ds_page = self.page
        self.assertEqual(1, all_ds_page.get_datasenders_count())
コード例 #20
0
    def test_intregation_of_application(self):

        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        login_page = LoginPage(self.driver)
        registration_page = login_page.navigate_to_registration_page()
        self.assertEqual(registration_page.get_title(), "Register")

        registration_confirmation_page, self.email = registration_page.successful_registration_with(
            REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION)
        self.assertEquals(
            registration_confirmation_page.registration_success_message(),
            fetch_(SUCCESS_MESSAGE,
                   from_(REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION)))

        dbmanager = DatabaseManager()
        organization_sms_tel_number = get_epoch_last_ten_digit()
        dbmanager.set_sms_telephone_number(organization_sms_tel_number,
                                           self.email)

        account_activate_page = ActivateAccountPage(self.driver)
        dbmanager = DatabaseManager()
        activation_code = dbmanager.get_activation_code(self.email)
        account_activate_page.activate_account(activation_code)
        self.assertRegexpMatches(
            account_activate_page.get_message(),
            fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS)))

        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        VALID_LOGIN_CREDENTIALS = VALID_CREDENTIALS
        VALID_LOGIN_CREDENTIALS[USERNAME] = self.email
        dashboard_page = login_page.do_successful_login_with(
            VALID_LOGIN_CREDENTIALS)
        self.assertEqual(
            dashboard_page.welcome_message(),
            fetch_(WELCOME_MESSAGE, from_(VALID_LOGIN_CREDENTIALS)))

        register_reporter_page = dashboard_page.navigate_to_register_reporter_page(
        )
        register_reporter_page.register_with(VALID_DATA_FOR_REPORTER)
        self.assertRegexpMatches(
            register_reporter_page.get_success_message(),
            fetch_(SUCCESS_MESSAGE, from_(VALID_DATA_FOR_REPORTER)))

        self.driver.go_to(DATA_WINNER_ADD_SUBJECT)
        add_subject_type_page = AddSubjectTypePage(self.driver)
        add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE1)
        self.assertEqual(add_subject_type_page.get_flash_message(),
                         fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE1)))
        add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE2)
        self.assertEqual(add_subject_type_page.get_flash_message(),
                         fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE2)))

        self.driver.go_to(DATA_WINNER_HOME_PAGE)
        register_subject_page = dashboard_page.navigate_to_register_subject_page(
        )
        message = register_subject_page.successfully_register_subject_with(
            VALID_DATA_FOR_SUBJECT)
        self.assertRegexpMatches(register_subject_page.get_flash_message(),
                                 message)

        self.driver.go_to(DATA_WINNER_HOME_PAGE)
        create_project_page = dashboard_page.navigate_to_create_project_page()
        create_subject_questionnaire_page = create_project_page.successfully_create_project_with(
            VALID_DATA_FOR_PROJECT)
        self.assertRegexpMatches(
            create_subject_questionnaire_page.get_title(),
            fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_PROJECT)))

        create_questionnaire_page = create_subject_questionnaire_page.successfully_create_subject_questionnaire_with(
            None)
        self.assertRegexpMatches(
            create_questionnaire_page.get_title(),
            fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_SUBJECT_QUESTIONNAIRE)))

        create_questionnaire_page.create_questionnaire_with(QUESTIONNAIRE_DATA)
        index = 2
        for question in fetch_(QUESTIONS, from_(QUESTIONNAIRE_DATA)):
            question_link_text = fetch_(QUESTION,
                                        from_(question)) + " " + fetch_(
                                            CODE, from_(question))
            self.assertEquals(
                create_questionnaire_page.get_question_link_text(index),
                question_link_text)
            index += 1
        time.sleep(5)
        self.assertEquals(
            create_questionnaire_page.get_remaining_character_count(),
            fetch_(CHARACTER_REMAINING, from_(QUESTIONNAIRE_DATA)))
        create_questionnaire_page.save_questionnaire()
        time.sleep(3)
        self.assertEqual(create_questionnaire_page.get_title(),
                         "Finish & Test")
        self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE)
        sms_tester_page = SMSTesterPage(self.driver)
        sms_tester_data = VALID_DATA_FOR_SMS
        sms_tester_data[RECEIVER] = organization_sms_tel_number
        sms_tester_page.send_sms_with(sms_tester_data)
        self.assertEqual(sms_tester_page.get_response_message(),
                         fetch_(SUCCESS_MESSAGE, from_(sms_tester_data)))

        self.driver.go_to(DATA_WINNER_HOME_PAGE)
        view_all_project_page = dashboard_page.navigate_to_view_all_project_page(
        )
        time.sleep(3)
        project_overview_project = view_all_project_page.navigate_to_project_page(
            fetch_(PROJECT_NAME, VALID_DATA_FOR_PROJECT))
        time.sleep(3)
        data_page = project_overview_project.navigate_to_data_page()
        time.sleep(3)
        submission_log_page = data_page.navigate_to_all_data_record_page()
        time.sleep(3)
        self.assertRegexpMatches(
            submission_log_page.get_submission_message(SMS_DATA_LOG),
            fetch_(SMS_SUBMISSION, from_(SMS_DATA_LOG)))

        self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE)
        sms_tester_data = VALID_DATA_FOR_SMS
        sms_tester_data[RECEIVER] = organization_sms_tel_number
        sms_tester_page.send_sms_with(sms_tester_data)
        self.assertEqual(sms_tester_page.get_response_message(),
                         fetch_(SUCCESS_MESSAGE, from_(sms_tester_data)))
コード例 #21
0
 def prepare_data_for_showing_only_logs_for_current_organization(cls):
     confirmation_page, cls.email = register_and_get_email(cls.driver)
     account_activate_page = ActivateAccountPage(cls.driver)
     dbmanager = DatabaseManager()
     activation_code = dbmanager.get_activation_code(cls.email.lower())
     account_activate_page.activate_account(activation_code)
コード例 #22
0
def activate_account(driver, email):
    account_activate_page = ActivateAccountPage(driver)
    dbmanager = DatabaseManager()
    activation_code = dbmanager.get_activation_code(email)
    account_activate_page.activate_account(activation_code)
    return account_activate_page
コード例 #23
0
 def set_organization_number(self):
     dbmanager = DatabaseManager()
     organization_sms_tel_number = get_epoch_last_ten_digit()
     dbmanager.set_sms_telephone_number(organization_sms_tel_number,
                                        self.email.lower())
     return organization_sms_tel_number
コード例 #24
0
    def test_intregation_of_application(self):

        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        login_page = LoginPage(self.driver)
        registration_page = login_page.navigate_to_registration_page()
        self.assertEqual(registration_page.get_title(), "Register")

        registration_confirmation_page, self.email = registration_page.successful_registration_with(REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION)
        self.assertEquals(registration_confirmation_page.registration_success_message(),
            fetch_(SUCCESS_MESSAGE, from_(REGISTRATION_DATA_FOR_SUCCESSFUL_REGISTRATION)))

        dbmanager = DatabaseManager()
        organization_sms_tel_number = get_epoch_last_ten_digit()
        dbmanager.set_sms_telephone_number(organization_sms_tel_number, self.email)

        account_activate_page = ActivateAccountPage(self.driver)
        dbmanager = DatabaseManager()
        activation_code = dbmanager.get_activation_code(self.email)
        account_activate_page.activate_account(activation_code)
        self.assertRegexpMatches(account_activate_page.get_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_ACTIVATION_DETAILS)))

        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        VALID_LOGIN_CREDENTIALS = VALID_CREDENTIALS
        VALID_LOGIN_CREDENTIALS[USERNAME] = self.email
        dashboard_page = login_page.do_successful_login_with(VALID_LOGIN_CREDENTIALS)
        self.assertEqual(dashboard_page.welcome_message(), fetch_(WELCOME_MESSAGE, from_(VALID_LOGIN_CREDENTIALS)))

        register_reporter_page = dashboard_page.navigate_to_register_reporter_page()
        register_reporter_page.register_with(VALID_DATA_FOR_REPORTER)
        self.assertRegexpMatches(register_reporter_page.get_success_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_DATA_FOR_REPORTER)))

        self.driver.go_to(DATA_WINNER_ADD_SUBJECT)
        add_subject_type_page = AddSubjectTypePage(self.driver)
        add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE1)
        self.assertEqual(add_subject_type_page.get_flash_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE1)))
        add_subject_type_page.add_entity_type_with(VALID_SUBJECT_TYPE2)
        self.assertEqual(add_subject_type_page.get_flash_message(), fetch_(SUCCESS_MESSAGE, from_(VALID_SUBJECT_TYPE2)))

        self.driver.go_to(DATA_WINNER_HOME_PAGE)
        register_subject_page = dashboard_page.navigate_to_register_subject_page()
        message = register_subject_page.successfully_register_subject_with(VALID_DATA_FOR_SUBJECT)
        self.assertRegexpMatches(register_subject_page.get_flash_message(), message)

        self.driver.go_to(DATA_WINNER_HOME_PAGE)
        create_project_page = dashboard_page.navigate_to_create_project_page()
        create_subject_questionnaire_page = create_project_page.successfully_create_project_with(VALID_DATA_FOR_PROJECT)
        self.assertRegexpMatches(create_subject_questionnaire_page.get_title(),
                                 fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_PROJECT)))

        create_questionnaire_page = create_subject_questionnaire_page.successfully_create_subject_questionnaire_with(None)
        self.assertRegexpMatches(create_questionnaire_page.get_title(),
                                 fetch_(PAGE_TITLE, from_(VALID_DATA_FOR_SUBJECT_QUESTIONNAIRE)))

        create_questionnaire_page.create_questionnaire_with(QUESTIONNAIRE_DATA)
        index = 2
        for question in fetch_(QUESTIONS, from_(QUESTIONNAIRE_DATA)):
            question_link_text = fetch_(QUESTION, from_(question)) + " " + fetch_(CODE, from_(question))
            self.assertEquals(create_questionnaire_page.get_question_link_text(index), question_link_text)
            index += 1
        time.sleep(5)
        self.assertEquals(create_questionnaire_page.get_remaining_character_count(),
                          fetch_(CHARACTER_REMAINING, from_(QUESTIONNAIRE_DATA)))
        create_questionnaire_page.save_questionnaire()
        time.sleep(3)
        self.assertEqual(create_questionnaire_page.get_title(), "Finish & Test")
        self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE)
        sms_tester_page = SMSTesterPage(self.driver)
        sms_tester_data = VALID_DATA_FOR_SMS
        sms_tester_data[RECEIVER] = organization_sms_tel_number
        sms_tester_page.send_sms_with(sms_tester_data)
        self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data)))

        self.driver.go_to(DATA_WINNER_HOME_PAGE)
        view_all_project_page = dashboard_page.navigate_to_view_all_project_page()
        time.sleep(3)
        project_overview_project = view_all_project_page.navigate_to_project_page(fetch_(PROJECT_NAME, VALID_DATA_FOR_PROJECT))
        time.sleep(3)
        data_page = project_overview_project.navigate_to_data_page()
        time.sleep(3)
        submission_log_page = data_page.navigate_to_all_data_record_page()
        time.sleep(3)
        self.assertRegexpMatches(submission_log_page.get_submission_message(SMS_DATA_LOG), fetch_(SMS_SUBMISSION, from_(SMS_DATA_LOG)))

        self.driver.go_to(DATA_WINNER_SMS_TESTER_PAGE)
        sms_tester_data = VALID_DATA_FOR_SMS
        sms_tester_data[RECEIVER] = organization_sms_tel_number
        sms_tester_page.send_sms_with(sms_tester_data)
        self.assertEqual(sms_tester_page.get_response_message(), fetch_(SUCCESS_MESSAGE, from_(sms_tester_data)))