Exemplo n.º 1
0
    def test_should_fetch_no_mobile_numbers_when_recipient_is_others(self):
        dbm = MagicMock(spec=DatabaseManager)
        request = MagicMock()
        request.POST = {'recipient': "others"}

        mobile_numbers = SendSMS(
        )._get_mobile_numbers_for_registered_data_senders(dbm, request)

        self.assertListEqual(mobile_numbers, [])
Exemplo n.º 2
0
    def test_should_return_unique_mobile_numbers(self):
        mock_request = MagicMock()
        mock_request.POST = {
            "others": "87687687,9879879, 9879879",
            "recipient": "others"
        }

        actual_numbers = SendSMS()._other_numbers(mock_request)
        expected_numbers = list(set(["87687687", "9879879"]))
        self.assertListEqual(actual_numbers, expected_numbers)
Exemplo n.º 3
0
    def test_should_fetch_mobile_numbers_for_given_questionnaire_names_when_recipient_is_linked(
            self):
        dbm = MagicMock(spec=DatabaseManager)
        request = MagicMock()
        request.POST = {
            'recipient': "linked",
            'questionnaire-names': '["questionnaire1", "questionnaire2"]'
        }

        with patch(
                "datawinners.entity.view.send_sms.SendSMS._mobile_numbers_for_questionnaire"
        ) as mock_mobile_numbers_for_questionnaire:
            mock_mobile_numbers_for_questionnaire.return_value = [
                "72465823", "4837539"
            ]

            mobile_numbers = SendSMS(
            )._get_mobile_numbers_for_registered_data_senders(dbm, request)

            mock_mobile_numbers_for_questionnaire.assert_called_once_with(
                dbm, ["questionnaire1", "questionnaire2"])

            self.assertListEqual(mobile_numbers, ["72465823", "4837539"])
Exemplo n.º 4
0
        name="edit_subject_questionnaire"),
    (r'subject/details/(?P<entity_type>.+?)/$',
     get_questionnaire_details_ajax),
    (r'questionnaire/save$', save_questionnaire),
    url(r'subject/export/', export_subject, name="export_subject"),
    url(r'entity/template/(?P<form_code>.+?)/$',
        import_template,
        name="import_template"),
    url(r'subjects/$', all_subject_types, name="all_subject_type_page"),
    url(r'subject/delete_types', delete_subject_types),
    url(r'questionnaires/$',
        get_existing_questionnaires,
        name="existing_questionnaires"),
    url(r'questionnairesandpolls/$',
        get_questionnaires_and_polls,
        name="existing_questionnaires_and_polls"),
    url(r'superusersindssearched/$',
        UsersInSearchedDataSender.as_view(),
        name="superusers_in_ds_searched"),
    url(r'send-sms/$', SendSMS.as_view(), name="send-sms"),
    url(r'get-all-mobile-numbers/$',
        get_all_mobile_numbers,
        name="get-all-mobile-numbers"),
    url(r'all-groups/$', get_group_names, name="all_groups"),
    url(r'update-contact-group/$',
        add_or_remove_contact_from_groups,
        name="add_or_remove_contact_from_groups"),
    url(r'group-ds-count/$', group_ds_count, name="group_ds_count"),
    url(r'delete-group/$', delete_group, name="group_delete"),
    url(r'rename-group/$', rename_group, name="group_rename"))