Exemplo n.º 1
0
 def test_creation_of_organization_id(self):
     id_creator = OrganizationIdCreator()
     id1 = id_creator.generateId()
     id2 = id_creator.generateId()
     self.assertTrue(id1)
     self.assertTrue(id2)
     self.assertFalse(id1 == id2)
 def test_creation_of_organization_id(self):
     id_creator = OrganizationIdCreator()
     id1 = id_creator.generateId()
     id2 = id_creator.generateId()
     self.assertTrue(id1)
     self.assertTrue(id2)
     self.assertFalse(id1 == id2)
 def prepare_organization(self):
     self.expired_organization_out_of_one_year = Organization(
         name='test_org_for_expired_organization_out_of_one_year',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         account_type='Basic',
         active_date=datetime.today() -
         relativedelta(years=settings.TRIAL_PERIOD_IN_YEAR, days=1),
         org_id=OrganizationIdCreator().generateId())
     self.paid_organization = Organization(
         name='test_org_for_paid_account',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         account_type='Pro SMS',
         active_date=datetime(2011, 8, 15),
         org_id=OrganizationIdCreator().generateId())
     self.unexpired_organization = Organization(
         name='test_org_for_unexpired_account',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         account_type='Basic',
         active_date=datetime.today(),
         org_id=OrganizationIdCreator().generateId())
     self.expired_organization_of_one_year = Organization(
         name='test_org_for_expired_organization_of_one_year',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         account_type='Basic',
         active_date=datetime.today() -
         relativedelta(years=settings.TRIAL_PERIOD_IN_YEAR),
         org_id=OrganizationIdCreator().generateId())
     self.expired_organization_of_one_year.save()
     self.expired_organization_out_of_one_year.save()
     self.unexpired_organization.save()
     self.paid_organization.save()
Exemplo n.º 4
0
 def prepare_organization(self):
     self.expired_organization_out_of_31_days = Organization(
         name='test_org_for_expired_organization_out_of_31_days',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         in_trial_mode=True,
         active_date=datetime.today() - timedelta(days=31),
         org_id=OrganizationIdCreator().generateId())
     self.paid_organization = Organization(
         name='test_org_for_paid_account',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         in_trial_mode=False,
         active_date=datetime(2011, 8, 15),
         org_id=OrganizationIdCreator().generateId())
     self.unexpired_organization = Organization(
         name='test_org_for_unexpired_account',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         in_trial_mode=True,
         active_date=datetime.today(),
         org_id=OrganizationIdCreator().generateId())
     self.expired_organization_of_30_days = Organization(
         name='test_org_for_expired_organization_of_30_days',
         sector='PublicHealth',
         address='add',
         city='xian',
         country='china',
         zipcode='10000',
         in_trial_mode=True,
         active_date=datetime.today() - timedelta(days=30),
         org_id=OrganizationIdCreator().generateId())
     self.expired_organization_of_30_days.save()
     self.expired_organization_out_of_31_days.save()
     self.unexpired_organization.save()
     self.paid_organization.save()
Exemplo n.º 5
0
 def create_trial_organization(cls, org_details):
     organization = Organization(
         name=org_details.get('organization_name'),
         sector=org_details.get('organization_sector'),
         city=org_details.get('organization_city'),
         country=org_details.get('organization_country'),
         org_id=OrganizationIdCreator().generateId(),
         in_trial_mode=True)
     organization._configure_organization_settings()
     return organization
Exemplo n.º 6
0
    def _prepare_organization(self):
        trial_organization = Organization(
            name='test_org_for_trial_account',
            sector='PublicHealth',
            address='add',
            city='Pune',
            country='IN',
            zipcode='411006',
            account_type='Basic',
            org_id=OrganizationIdCreator().generateId(),
            status='Activated')
        trial_organization.save()

        today = datetime.datetime.today()
        mt_current_month = MessageTracker(month=datetime.date(
            today.year, today.month, 12),
                                          incoming_web_count=7,
                                          incoming_sms_count=13,
                                          incoming_sp_count=5,
                                          sms_api_usage_count=3,
                                          sms_api_usage_charged_count=3,
                                          sms_registration_count=2,
                                          sent_reminders_count=10,
                                          sent_reminders_charged_count=10,
                                          send_message_count=0,
                                          send_message_charged_count=0,
                                          outgoing_sms_count=40,
                                          outgoing_sms_charged_count=40,
                                          organization=trial_organization)
        mt_current_month.save()
        mt_current_month = MessageTracker(month=datetime.date(
            today.year, today.month, 1),
                                          incoming_web_count=3,
                                          incoming_sms_count=20,
                                          incoming_sp_count=10,
                                          sms_api_usage_count=3,
                                          sms_registration_count=4,
                                          outgoing_sms_count=40,
                                          organization=trial_organization)
        mt_current_month.save()
        year = today.year
        month = today.month
        if today.month == 1:
            year -= 1
            month = 12
        mt_last_month = MessageTracker(month=datetime.date(year, month, 1),
                                       incoming_web_count=10,
                                       incoming_sms_count=10,
                                       incoming_sp_count=7,
                                       sms_api_usage_count=3,
                                       sms_registration_count=4,
                                       outgoing_sms_count=40,
                                       organization=trial_organization)
        mt_last_month.save()
        return trial_organization
Exemplo n.º 7
0
 def create_trial_organization(cls, org_details):
     organization = Organization(
         name=org_details.get('organization_name'),
         sector=org_details.get('organization_sector'),
         city=org_details.get('organization_city'),
         country=org_details.get('organization_country'),
         org_id=OrganizationIdCreator().generateId(),
         account_type='Basic',
         language=org_details.get('language'))
     organization._configure_organization_settings()
     return organization
Exemplo n.º 8
0
 def _prepare_organization(self):
     trial_organization = Organization(
         name='test_org_for_trial_account',
         sector='PublicHealth',
         address='add',
         city='Pune',
         country='IN',
         zipcode='411006',
         in_trial_mode=True,
         org_id=OrganizationIdCreator().generateId())
     trial_organization.save()
     return trial_organization
Exemplo n.º 9
0
    def prepare_organization(self):
        self.paid_organization = Organization(
            name='test_org_for_paid_account',
            sector='PublicHealth',
            address='add',
            city='Pune',
            country='India',
            zipcode='411006',
            account_type='Pro SMS',
            org_id=OrganizationIdCreator().generateId())

        self.trial_organization = Organization(
            name='test_org_for_trial_account',
            sector='PublicHealth',
            address='add',
            city='Pune',
            country='India',
            zipcode='411006',
            account_type='Basic',
            org_id=OrganizationIdCreator().generateId())
        self.paid_organization.save()
        self.trial_organization.save()
Exemplo n.º 10
0
 def test_is_pro_sms(self):
     pro_sms_organization = Organization(
         name='pro_sms_ngo',
         sector='Education',
         address='Fianar',
         city='Mahasoabe',
         country='IN',
         zipcode='301',
         account_type='Pro SMS',
         org_id=OrganizationIdCreator().generateId(),
         status='Activated')
     self.assertEqual(pro_sms_organization.is_pro_sms, True)
     self.assertEqual(pro_sms_organization.in_trial_mode, False)
Exemplo n.º 11
0
 def create_organization(self, active_date=None):
     organization = Organization(
         name='twu',
         sector='Gaoxin',
         address='xian',
         city='Xian',
         state='ShanXi',
         country='CHN',
         zipcode='730000',
         office_phone='12345678911',
         website='http://google.com',
         active_date=active_date,
         org_id=OrganizationIdCreator().generateId())
     organization.in_trial_mode = True
     return organization
Exemplo n.º 12
0
 def create_organization(cls, org_details):
     organization = Organization(
         name=org_details.get('organization_name'),
         sector=org_details.get('organization_sector'),
         address=org_details.get('organization_address'),
         addressline2=org_details.get('organization_addressline2'),
         city=org_details.get('organization_city'),
         state=org_details.get('organization_state'),
         country=org_details.get('organization_country'),
         zipcode=org_details.get('organization_zipcode'),
         office_phone=org_details.get('organization_office_phone'),
         website=org_details.get('organization_website'),
         org_id=OrganizationIdCreator().generateId())
     organization._configure_organization_settings()
     return organization
Exemplo n.º 13
0
    def test_user_email_validation_should_be_case_insensitive(self):
        User.objects.create_user('*****@*****.**', '*****@*****.**', 'password')
        trial_organization = Organization(
            name='test_org_for_trial_account',
            sector='PublicHealth',
            address='add',
            city='Pune',
            country='IN',
            zipcode='411006',
            account_type='Basic',
            org_id=OrganizationIdCreator().generateId(),
            status='Activated')
        trial_organization.save()
        mobile_validater = MobileNumberValidater(trial_organization, '788522',
                                                 'no_id')
        mobile_validater.validate = MagicMock(return_value=(True, ''))
        with patch("datawinners.accountmanagement.forms.MobileNumberValidater"
                   ) as validater:
            with patch(
                    "datawinners.accountmanagement.forms.datasender_count_with"
            ) as datasender_count_with_mock:
                validater.return_value = mobile_validater
                form = UserProfileForm(organization=trial_organization,
                                       data={
                                           'title': 'manager',
                                           'full_name': 'user one',
                                           'username': '******',
                                           'mobile_phone': '7889522'
                                       })

                self.assertFalse(form.is_valid())
                self.assertEqual(form.errors['username'], [
                    'This email address is already in use. Please supply a different email address'
                ])
                mobile_validater.validate.assert_called_with()
                datasender_count_with_mock.return_value = 0
                form = UserProfileForm(organization=trial_organization,
                                       data={
                                           'title': 'manager',
                                           'full_name': 'user one',
                                           'username': '******',
                                           'mobile_phone': '7889522'
                                       })

                self.assertTrue(form.is_valid())
                self.assertEqual(form.clean_username(), '*****@*****.**')
Exemplo n.º 14
0
def create_organization(org_details):
    organization = Organization(
        name=org_details.get('organization_name'),
        sector=org_details.get('organization_sector'),
        address=org_details.get('organization_address'),
        city=org_details.get('organization_city'),
        state=org_details.get('organization_state'),
        country=org_details.get('organization_country'),
        zipcode=org_details.get('organization_zipcode'),
        office_phone=org_details.get('organization_office_phone'),
        website=org_details.get('organization_website'),
        org_id=OrganizationIdCreator().generateId())
    organization.save()
    organization_setting = OrganizationSetting()
    organization_setting.organization = organization
    organization_setting.document_store = slugify(
        "%s_%s_%s" % ("HNI", organization.name, organization.org_id))
    organization_setting.save()
    return organization
    def test_user_email_validation_should_be_case_insensitive(self):
        User.objects.create_user('*****@*****.**', '*****@*****.**', 'password')
        trial_organization = Organization(
            name='test_org_for_trial_account',
            sector='PublicHealth',
            address='add',
            city='Pune',
            country='IN',
            zipcode='411006',
            account_type='Basic',
            org_id=OrganizationIdCreator().generateId(),
            status='Activated')
        trial_organization.save()

        form = UserProfileForm(organization=trial_organization,
                               data={
                                   'title': 'manager',
                                   'full_name': 'user one',
                                   'username': '******',
                                   'mobile_phone': '7889522'
                               })

        self.assertFalse(form.is_valid())
        self.assertEqual(form.errors['username'], [
            'This email address is already in use. Please supply a different email address'
        ])

        form = UserProfileForm(organization=trial_organization,
                               data={
                                   'title': 'manager',
                                   'full_name': 'user one',
                                   'username': '******',
                                   'mobile_phone': '7889522'
                               })

        self.assertTrue(form.is_valid())
        self.assertEqual(form.clean_username(), '*****@*****.**')
Exemplo n.º 16
0
 def setUp(self):
     self.user = self._prepare_test_user()
     self.org_id = OrganizationIdCreator().generateId()
     self.create_organization()
     self.admin = FakeUserAdmin(self.org_id)
Exemplo n.º 17
0
 def test_should_raise_a_trial_account_expired_exception_if_trial_account_is_expired(
         self):
     self.org_id = OrganizationIdCreator().generateId()
     self.create_organization()
     form = FakeForm(org_id=self.org_id)
     form.check_trial_account_expired()