def test_should_update_submission_log_when_subject_info_is_edited(self):
        self.driver.go_to(url("/entity/subject/create/clinic/?web_view=True&"))
        add_subject_page = AddSubjectPage(self.driver)
        add_subject_page.add_subject_with(VALID_DATA_FOR_SUBJECT)
        add_subject_page.submit_subject()
        message = fetch_(SUCCESS_MESSAGE, from_(VALID_DATA_FOR_SUBJECT))

        flash_message = add_subject_page.get_flash_message()
        subject_short_code = get_subject_short_code(flash_message)
        message = message % subject_short_code
        self.assertIn(message, flash_message)

        VALID_SMS_FOR_EDIT_SUBJECT[SMS] = VALID_SMS_FOR_EDIT_SUBJECT[
            SMS].replace('short_code', subject_short_code, 1)
        send_valid_sms_with(VALID_SMS_FOR_EDIT_SUBJECT)

        submission_log_page = self.get_first_project_submission_log_page()
        submission_log_page.search(subject_short_code)
        self.assertIn(fetch_(SUB_LAST_NAME, VALID_DATA_FOR_SUBJECT),
                      submission_log_page.get_cell_value(1, 5))

        self.driver.go_to(url("/entity/subjects/clinic/"))
        subject_list_page = AllSubjectsListPage(self.driver)
        self.driver.wait_for_page_load()
        subject_list_page.select_subject_by_id(subject_short_code)
        edit_subject_page = subject_list_page.click_edit_action_button()
        edit_subject_page.add_subject_with(VALID_DATA_FOR_EDIT)
        edit_subject_page.submit_subject()

        submission_log_page = self.get_first_project_submission_log_page()
        submission_log_page.search(subject_short_code)
        self.assertIn(fetch_(SUB_LAST_NAME, VALID_DATA_FOR_EDIT),
                      submission_log_page.get_cell_value(1, 5))
Exemple #2
0
    def test_should_get_form_data_by_form_code_and_only_start_date(self):
        response = requests.get(url('/api/get_for_form/cli/03-08-2012/'), auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 200)


        response = requests.get(url('/api/registereddata/clinic/01-08-2012/03082012/'), auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 404)
Exemple #3
0
 def test_add_duplicate_subjectType(self):
     self.driver.go_to(url("/entity/subjects/"))
     subjects_page = AddSubjectTypePage(self.driver)
     subject_type_name = SUBJECT_TYPE + random_string(3)
     response = subjects_page.add_subject_type(subject_type_name)
     self.driver.go_to(url("/entity/subjects/"))
     self.validate_subject_type(subject_type_name)
     response = subjects_page.add_subject_type(subject_type_name)
     self.assertEqual(response['message'], subject_type_name+" already exists.")
Exemple #4
0
    def test_should_return_404_response_status_when_date_format_is_invalid(
            self):
        response = requests.get(url('/api/registereddata/clinic/2/'),
                                auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 404)

        response = requests.get(
            url('/api/registereddata/clinic/01-08-2012/03082012/'),
            auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 404)
Exemple #5
0
    def test_should_render_get_registgered_data_response_if_logged_in(self):
        response = requests.get(url('/api/registereddata/clinic/'),
                                auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 200)

        response = requests.get(url('/api/registereddata/clinic/01-08-2012/'),
                                auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 200)

        response = requests.get(
            url('/api/registereddata/clinic/01-08-2012/03-08-2012/'),
            auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 200)
Exemple #6
0
    def test_add_invalid_subjectType(self):
        self.driver.go_to(url("/entity/subjects/"))
        subjects_page = AddSubjectTypePage(self.driver)
        response = subjects_page.add_subject_type(SUBJECT_TYPE_WHITE_SPACES)
        self.assertEqual(response['message'], ERROR_MSG_INVALID_ENTRY)

        self.driver.go_to(url("/entity/subjects/"))
        subjects_page = AddSubjectTypePage(self.driver)
        response = subjects_page.add_subject_type(SUBJECT_TYPE_SPL_CHARS)
        self.assertEqual(response['message'], ERROR_MSG_INVALID_ENTRY)

        self.driver.go_to(url("/entity/subjects/"))
        subjects_page = AddSubjectTypePage(self.driver)
        response = subjects_page.add_subject_type(SUBJECT_TYPE_BLANK)
        self.assertEqual(response['message'], ERROR_MSG_EMPTY_ENTRY)
    def test_create_and_activate_datasender(self):
        self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
        login_page = LoginPage(self.driver)
        global_navigation_page = login_page.do_successful_login_with(
            VALID_CREDENTIALS)
        add_datasender_page = global_navigation_page.navigate_to_all_data_sender_page(
        ).navigate_to_add_a_data_sender_page()
        email = generate_random_email_id()
        add_datasender_page.enter_data_sender_details_from(VALID_DATASENDER,
                                                           email=email)
        success_message = add_datasender_page.get_success_message()
        self.assertIn(VALID_DATASENDER[SUCCESS_MSG], success_message)
        rep_id = add_datasender_page.get_rep_id_from_success_message(
            success_message)
        add_datasender_page.close_add_datasender_dialog()
        all_datasender_page = global_navigation_page.navigate_to_all_data_sender_page(
        )
        all_datasender_page.associate_datasender_to_projects(
            rep_id, ["clinic test project1"])
        self.driver.go_to(LOGOUT)

        user = User.objects.get(username=email)
        token = default_token_generator.make_token(user)
        self.driver.go_to(
            url(DS_ACTIVATION_URL % (int_to_base36(user.id), token)))
        activation_page = ResetPasswordPage(self.driver)
        activation_page.type_same_password(NEW_PASSWORD)
        activation_page.click_submit()
        self.driver.wait_for_page_with_title(UI_TEST_TIMEOUT,
                                             "Data Submission")
        self.assertEqual(self.driver.get_title(), "Data Submission")
Exemple #8
0
    def test_should_add_question_successfully(self):
        login(self.driver)
        self.driver.go_to(url("/entity/subjects/"))
        add_subject_type_page = AddSubjectTypePage(self.driver)
        add_subject_type_page.click_on_accordian_link()
        entity_type = VALID_ENTITY[ENTITY_TYPE] + generateId()
        add_subject_type_page.successfully_add_entity_type_with(entity_type)
        self.driver.go_to(url("/entity/subject/create/" + entity_type))
        subjects_page = ProjectSubjectsPage(self.driver)
        subjects_page.click_edit_form_link_and_continue()
        subjects_page.click_add_question_link()

        self.assertEqual("Question", subjects_page.get_selected_question_label())

        subjects_page.click_submit_button()
        self.assertTrue(subjects_page.is_success_message_tip_show())
Exemple #9
0
    def test_should_return_unique_ids_for_given_form_code(self):
        response = requests.get(url('/api/unique-id/wat/'), auth=self.DIGEST_CREDENTIALS)
        self.assertEquals(response.status_code, 200)
        response_body = json.loads(response.content)
        unique_ids_ = response_body['unique-ids']
        self.assertEqual(len(unique_ids_), 3)
        self.assertDictEqual(unique_ids_[0], {u'geo_code': u'23.0395677, 72.566005', u'name': u'Test',
                                              u'firstname': u'Ahmedabad waterpoint', u'short_code': u'wp01',
                                              u'deleted': False, u'location': u'India,Gujrat,Ahmedabad',
                                              u'mobile_number': u'1234563'})

        self.assertDictEqual(unique_ids_[1], {u'geo_code': u'28.46385, 77.017838', u'name': u'Test',
                                              u'firstname': u'Gurgaon waterpoint', u'short_code': u'wp03',
                                              u'deleted': False, u'location': u'India,Haryana,Gurgaon',
                                              u'mobile_number': u'1234564'})

        self.assertDictEqual(unique_ids_[2],
                             {u'geo_code': u'23.251671, 69.66256', u'name': u'Test', u'firstname': u'Bhuj waterpoint',
                              u'short_code': u'wp02', u'deleted': False, u'location': u'India,Gujrat,Bhuj',
                              u'mobile_number': u'1234564'})


        self.assertDictEqual(response_body['questionnaire'],
                             {u'geo_code': u"What is the waterpoint's GPS co-ordinates?",
                              u'name': u"What is the waterpoint's last name?",
                              u'firstname': u"What is the waterpoint's first name?",
                              u'short_code': u"What is the waterpoint's Unique ID Number?",
                              u'location': u"What is the waterpoint's location?",
                              u'mobile_number': u"What is the waterpoint's mobile telephone number?"})
Exemple #10
0
    def test_sms_player_for_registration_of_new_subject(self):

        organization = Organization.objects.get(org_id=DEFAULT_TEST_ORG_ID)
        message_tracker_before = organization._get_message_tracker(
            datetime.today())
        response = send_sms_with(REGISTER_NEW_SUBJECT)
        self.assertTrue(
            fetch_(SUCCESS_MESSAGE, from_(REGISTER_NEW_SUBJECT)) in response)
        message_tracker_after = organization._get_message_tracker(
            datetime.today())
        self.assertEqual(message_tracker_before.incoming_sms_count + 1,
                         message_tracker_after.incoming_sms_count)
        self.assertEqual(message_tracker_before.sms_registration_count + 1,
                         message_tracker_after.sms_registration_count)
        code = response.split(" ")[-1].rstrip(".")
        self._delete_unique_id(code, 'clinic')

        all_deleted_subjects = json.loads(
            requests.get(url('/api/entity/actions/'),
                         auth=self.DIGEST_CREDENTIALS).content)
        deleted_subjects = [
            dict for dict in all_deleted_subjects
            if dict['entity_type'] == 'clinic'
            and dict['action'] == 'hard-delete' and dict['short_code'] == code
        ]
        self.assertGreaterEqual(len(deleted_subjects), 1)
Exemple #11
0
 def register_trial_account(self):
     self.driver.go_to(url("/register/trial"))
     registration_page = RegistrationPage(self.driver)
     registration_confirmation_page, email = registration_page.successful_registration_with(
         REGISTRATION_DATA_FOR_SUCCESSFUL_TRIAL_REGISTRATION)
     self.assertEquals(registration_confirmation_page.registration_success_message(),
                       SUCCESS_MESSAGE)
 def navigate_to_edit_registration_form(self,
                                        entity_type,
                                        close_warning=False):
     self.driver.go_to(url("/entity/subject/edit/%s/" %
                           entity_type.lower()))
     if close_warning:
         self.driver.find(CONTINUE_EDITING_BUTTON).click()
     return CreateQuestionnairePage(self.driver)
def send_sms_with(sms):
    data = {
        "message": sms[SMS],
        "from_msisdn": sms[SENDER],
        "to_msisdn": sms[RECEIVER],
        "message_id": uuid.uuid1().hex
    }
    resp = requests.post(url("/") + "submission", data)
    return resp.content
Exemple #14
0
 def test_should_delete_cache_after_edit_subject(self):
     self.driver.go_to(url("/entity/subjects/"))
     add_subject_type_page = AddSubjectTypePage(self.driver)
     add_subject_type_page.click_on_accordian_link()
     entity_type = "alia"
     add_subject_type_page.successfully_add_entity_type_with(entity_type)
     self.driver.go_to(url("/entity/subject/create/" + entity_type))
     subjects_page = ProjectSubjectsPage(self.driver)
     subjects_page.click_edit_form_link_and_continue()
     from framework.utils.common_utils import by_css
     self.driver.find_text_box(
         by_css("#questionnaire-code")).enter_text("als")
     subjects_page.click_submit_button()
     self.driver.go_to(url("/entity/subjects/"))
     add_subject_type_page = AddSubjectTypePage(self.driver)
     add_subject_type_page.click_on_accordian_link()
     new_entity_type = "alida"
     add_subject_type_page.successfully_add_entity_type_with(
         new_entity_type)
Exemple #15
0
 def _verify_entity_action(self, subject_type):
     subjects_deleted = json.loads(
         requests.get(url('/api/entity/actions/'),
                      auth=self.DIGEST_CREDENTIALS).content)
     deleted_subjects = [
         dict for dict in subjects_deleted
         if dict['entity_type'] == subject_type
         and dict['action'] == 'hard-delete'
     ]
     self.assertEqual(len(deleted_subjects), 1)
 def test_add_invalid_subjectType(self):
     self.driver.go_to(url("/entity/subjects/"))
     self.add_subject_type(SUBJECT_TYPE_WHITE_SPACES)
     self.validate_error_messages(ERROR_MSG_INVALID_ENTRY)
     self.driver.find(by_id("cancel_add_type")).click()
     self.add_subject_type(SUBJECT_TYPE_SPL_CHARS)
     self.validate_error_messages(ERROR_MSG_INVALID_ENTRY)
     self.driver.find(by_id("cancel_add_type")).click()
     self.add_subject_type(SUBJECT_TYPE_BLANK)
     self.validate_error_messages(ERROR_MSG_EMPTY_ENTRY)
 def open_clinic5_project_and_send_msg_via_test_sms_questionnaire(
         self, message):
     self.driver.go_to(url("/project/"))
     all_project_page = ProjectsPage(self.driver)
     project_overview_page = all_project_page.navigate_to_project_overview_page(
         "clinic5 test project")
     sms_tester_page = project_overview_page.open_sms_tester_light_box()
     sms_tester_page.hit_clear_message_link()
     sms_tester_page.send_sms_with(message)
     self.wait_while_loading()
     return sms_tester_page
Exemple #18
0
 def _delete_unique_id(self, unique_id, unique_id_type):
     request = {
         'all_ids': unique_id,
         'entity_type': unique_id_type,
         'all_selected': False
     }
     client = Client()
     client.login(username='******',
                  password='******')
     response = client.post(url('/entity/subjects/delete/'), request)
     self.assertEquals(response.status_code, 200)
Exemple #19
0
    def activate_datasender(self, email, password):
        client = Client()
        client.login(username='******', password='******')
        r = client.post(path='/admin-apis/datasender/generate_token/', data={'ds_email': email})
        resp = json.loads(r._container[0])
        self.driver.go_to(url(DS_ACTIVATION_URL % (resp["user_id"], resp["token"])))
        activation_page = ResetPasswordPage(self.driver)
        activation_page.type_same_password(password)
        activation_page.click_submit()

        return self
Exemple #20
0
    def test_should_add_question_successfully(self):
        self.driver.go_to(url("/entity/subjects/"))
        add_subject_type_page = AddSubjectTypePage(self.driver)
        add_subject_type_page.click_on_accordian_link()
        entity_type = VALID_ENTITY[ENTITY_TYPE] + generateId()
        add_subject_type_page.successfully_add_entity_type_with(entity_type)
        self.driver.go_to(url("/entity/subject/create/" + entity_type))
        subjects_page = ProjectSubjectsPage(self.driver)
        subjects_page.click_edit_form_link_and_continue()
        subjects_page.click_add_question_link()
        subjects_page.type_question_name('New Question')
        subjects_page.choose_question_type('text')
        self.assertEqual("New Question",
                         subjects_page.get_selected_question_label())

        existing_question_count = subjects_page.get_existing_questions_count()

        subjects_page.click_submit_button()
        self.assertTrue(subjects_page.is_success_message_tip_show())
        subjects_page.refresh()
        self.assertEqual(subjects_page.get_existing_questions_count(),
                         existing_question_count,
                         "Newly added question should be persisted")
    def test_all_subjects_page(self):
        self.driver.go_to(url("/entity/subjects/clinic/"))
        subjects_page = AllSubjectsListPage(self.driver)
        self.check_pagination_size(subjects_page, 25)

        subjects_page.set_page_size(10)
        self.check_pagination_size(subjects_page, 10)

        subjects_page.search("tes")

        self.check_pagination_size(subjects_page, 10)

        sleep(1)
        for row in subjects_page.rows()[1:]:
            self.assertIn("tes", row.text.lower())
Exemple #22
0
 def verify_submission_via_web(self, ds_email):
     self.driver.go_to(LOGOUT)
     user = User.objects.get(username=ds_email)
     token = default_token_generator.make_token(user)
     self.driver.go_to(
         url(DS_ACTIVATION_URL % (int_to_base36(user.id), token)))
     activation_page = ResetPasswordPage(self.driver)
     activation_page.type_same_password(NEW_PASSWORD)
     activation_page.click_submit()
     self.driver.wait_for_page_with_title(UI_TEST_TIMEOUT,
                                          "Data Submission")
     self.assertEqual(self.driver.get_title(), "Data Submission")
     self.driver.go_to(LOGOUT)
     self.driver.go_to(DATA_WINNER_LOGIN_PAGE)
     login_page = LoginPage(self.driver)
     login_page.login_with({USERNAME: ds_email, PASSWORD: NEW_PASSWORD})
     data_sender_page = DataSenderPage(self.driver)
     submission_page = data_sender_page.send_in_data()
     submission_page.fill_and_submit_answer(WEB_ANSWERS)
     self.driver.go_to(LOGOUT)
     self.do_login()
     self.verify_submission(WEB_ANSWER_LOG, self.project_name)
EDITED_DATA_SENDER = {NAME: "aaa Mickey Goose",
                      MOBILE_NUMBER: random_number(9),
                      COMMUNE: "Pakistan",
                      EMAIL_ADDRESS: "goose",
                      GPS: "3.33, 1.11",
                      SUCCESS_MSG: "Your changes have been saved."}

INVALID_MOBILE_NUMBER_DATA = {NAME: "ReRegistered",
                              MOBILE_NUMBER: "abcdefgh",
                              COMMUNE: "MAHAVELO,AMBOTAKA,MANAKARA ATSIMO,VATOVAVY FITOVINANY",
                              GPS: "-21.7622088847 48.0690991394"}

ALL_DS_TO_DELETE_ARE_USER_MSG = u'You cannot delete the following Data Senders as they are DataWinners users:'
NOTIFICATION_WHILE_DELETING_USER = "******"

ALL_USERS_URL = url("/account/users/")
TITLE = "title"
FIRST_NAME = "full_name"
USERNAME = "******"
MOBILE_PHONE = "mobile_phone"

NEW_USER_DATA = {
    TITLE: "Developer",
    FIRST_NAME: "AllDSDelete user",
    USERNAME: random_string(4) + "@mailinator.com",
    MOBILE_PHONE: random_number(9)
}


QUESTIONNAIRE_CODE = "questionnaire_code"
GEN_RANDOM = "gen_random"
Exemple #24
0
 def test_should_return_authentication_required_status_when_query_register_data_without_auth(self):
     response = requests.get(url('/api/get_for_subject/clinic/cid001/'))
     self.assertEquals(response.status_code, 404)
Exemple #25
0
 def get_data_by_uri(self, uri):
     http_response = requests.get(url(uri), auth=self.DIGEST_CREDENTIALS)
     return json.loads(http_response.content)
Exemple #26
0
    def test_should_check_with_right_order(self):
        test_data = MULTIPLE_WRONG_DATA.copy()
        test_data['from'] = "4938429843743"
        paid_test_org = Organization.objects.get(org_id=DEFAULT_TEST_ORG_ID)
        print test_data
        self.assertEqual(
            send_sms_with(test_data),
            "Error. You are not registered as a Data Sender. Please contact your supervisor."
        )

        test_data.update({SENDER: "2619876"})
        msg = send_sms_with(test_data)
        self.assertEqual(
            msg,
            "Error. Questionnaire Code wrcode is incorrect. Find the Code on the top of the printed Questionnaire and resend SMS starting with this Code."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("wrcode", "cli002")})
        test_data.update({SENDER: "1234567892"})
        count_before_submission = (self._get_test_paid_org_message_tracker(
            paid_test_org)).incoming_sms_count
        self.assertEqual(
            send_sms_with(test_data),
            "Error. You are not authorized to submit data for this Questionnaire. Please contact your supervisor."
        )
        self.assertEqual(
            count_before_submission + 1,
            self._get_test_paid_org_message_tracker(
                paid_test_org).incoming_sms_count)

        test_data.update({SENDER: "1234567890"})
        count_before_submission = (self._get_test_paid_org_message_tracker(
            paid_test_org)).incoming_sms_count
        self.assertEqual(
            send_sms_with(test_data),
            "Error. Incorrect number of responses. Please review printed Questionnaire and resend entire SMS."
        )
        self.assertEqual(
            count_before_submission + 1,
            self._get_test_paid_org_message_tracker(
                paid_test_org).incoming_sms_count)

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("extradata", "")})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. cid00x5 is not registered. Check the Identification Number and resend entire SMS or contact your supervisor."
        )

        code = self._register_subject_clinic()

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("CID00X5", code)})
        self.assertEqual(
            send_sms_with(test_data),
            "Error. Incorrect answer for question 3. Please review printed Questionnaire and resend entire SMS."
        )

        message = fetch_(SMS, from_(test_data))
        test_data.update({SMS: message.replace("age", "56")})
        count_before_submission = (self._get_test_paid_org_message_tracker(
            paid_test_org)).incoming_sms_count
        self.assertEqual(send_sms_with(test_data),
                         "Thank you Shweta. We received your SMS.")
        self.assertEqual(
            count_before_submission + 1,
            self._get_test_paid_org_message_tracker(
                paid_test_org).incoming_sms_count)

        self._delete_unique_id(code, 'clinic')
        all_deleted_subjects = json.loads(
            requests.get(url('/api/entity/actions/'),
                         auth=self.DIGEST_CREDENTIALS).content)
        deleted_subjects = [
            dict for dict in all_deleted_subjects
            if dict['entity_type'] == 'clinic'
            and dict['action'] == 'soft-delete' and dict['short_code'] == code
        ]
        self.assertGreaterEqual(len(deleted_subjects), 1)
Exemple #27
0
from framework.utils.common_utils import by_css
from testdata.test_data import url

USERNAME = '******'
PASSWORD = '******'

VALID_CREDENTIALS = {
    USERNAME: "******",
    PASSWORD: "******"
}
DATA_WINNERS_ACCOUNT_PAGE = url("/account/")
ORGANIZATION_SECTOR_DROP_DOWN_LIST = by_css("select#id_sector")
 def goto_dashboard(self):
     self.driver.go_to(url("/dashboard/"))
     return DashboardPage(self.driver)
Exemple #29
0
 def test_should_return_not_found_error_when_for_a_questionnaire_form_code(self):
     response = requests.get(url('/api/unique-id/cli001/'), auth=self.DIGEST_CREDENTIALS)
     self.assertEquals(response.status_code, 404)
Exemple #30
0
 def test_should_return_not_found_error_when_unique_id_does_not_exists_for_given_form_code(self):
     response = requests.get(url('/api/unique-id/random/'), auth=self.DIGEST_CREDENTIALS)
     self.assertEquals(response.status_code, 404)