Пример #1
0
 def test_input_triggers_proper_response(self):
     short_center_id = u'%s*%s' % (
         self.good_nid, get_random_number_string(length=constants.CENTER_ID_LENGTH - 1))
     long_center_id = u'%s*%s' % (
         self.good_nid, get_random_number_string(length=constants.CENTER_ID_LENGTH + 1))
     short_nid = u"%s*%s" % (
         get_random_number_string(length=constants.NID_LENGTH - 1), self.good_center_id)
     long_nid = u"%s*%s" % (
         get_random_number_string(length=constants.NID_LENGTH + 1), self.good_center_id)
     three_ids = u"%s*%s*123" % (self.good_nid, self.good_center_id)
     io_table = [
         (u"garbage", constants.MESSAGE_INCORRECT),
         (get_random_number_string(), constants.VOTER_QUERY_NID_WRONG_LENGTH),
         (short_center_id, constants.RESPONSE_CENTER_ID_WRONG_LENGTH),
         (long_center_id, constants.RESPONSE_CENTER_ID_WRONG_LENGTH),
         (short_nid, constants.RESPONSE_NID_WRONG_LENGTH),
         (long_nid, constants.RESPONSE_NID_WRONG_LENGTH),
         (three_ids, constants.MESSAGE_INCORRECT),
     ]
     # send the messages
     for (input, _) in io_table:
         self.receive(input, self.conn, fields=self.fields)
     # strip out our split messages
     outputs = [o.fields['message_code'] for o in self.outbound if not o.fields.get('split')]
     for (i, (_, expected_output)) in enumerate(io_table):
         self.assertEqual(outputs[i], expected_output)
Пример #2
0
 def setUp(self):
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH + 1)
     self.conn = self.create_connection()
     self.fields = {'to_addr': settings.VOTER_QUERY_SHORT_CODE}
     self.garbage = u"PING"
     self.good_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.good_center_id = get_random_number_string(length=constants.CENTER_ID_LENGTH)
Пример #3
0
 def test_input_triggers_proper_response(self):
     short_center_id = u'%s*%s' % (
         self.good_nid,
         get_random_number_string(length=constants.CENTER_ID_LENGTH - 1))
     long_center_id = u'%s*%s' % (
         self.good_nid,
         get_random_number_string(length=constants.CENTER_ID_LENGTH + 1))
     short_nid = u"%s*%s" % (get_random_number_string(
         length=constants.NID_LENGTH - 1), self.good_center_id)
     long_nid = u"%s*%s" % (get_random_number_string(
         length=constants.NID_LENGTH + 1), self.good_center_id)
     three_ids = u"%s*%s*123" % (self.good_nid, self.good_center_id)
     io_table = [
         (u"garbage", constants.MESSAGE_INCORRECT),
         (get_random_number_string(),
          constants.VOTER_QUERY_NID_WRONG_LENGTH),
         (short_center_id, constants.RESPONSE_CENTER_ID_WRONG_LENGTH),
         (long_center_id, constants.RESPONSE_CENTER_ID_WRONG_LENGTH),
         (short_nid, constants.RESPONSE_NID_WRONG_LENGTH),
         (long_nid, constants.RESPONSE_NID_WRONG_LENGTH),
         (three_ids, constants.MESSAGE_INCORRECT),
     ]
     # send the messages
     for (input, _) in io_table:
         self.receive(input, self.conn, fields=self.fields)
     # strip out our split messages
     outputs = [
         o.fields['message_code'] for o in self.outbound
         if not o.fields.get('split')
     ]
     for (i, (_, expected_output)) in enumerate(io_table):
         self.assertEqual(outputs[i], expected_output)
Пример #4
0
 def setUp(self):
     self.citizen = CitizenFactory()
     self.good_nid = self.citizen.national_id
     self.bad_nid = long(
         get_random_number_string(length=constants.NID_LENGTH))
     self.nid_without_citizen = long(
         get_random_number_string(length=constants.NID_LENGTH))
     self.sms = SMSFactory()
Пример #5
0
 def setUp(self):
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH +
                                             1)
     self.conn = self.create_connection()
     self.fields = {'to_addr': settings.VOTER_QUERY_SHORT_CODE}
     self.garbage = u"PING"
     self.good_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.good_center_id = get_random_number_string(
         length=constants.CENTER_ID_LENGTH)
 def setUp(self):
     self.conn = self.create_connection()
     self.fields = {'to_addr': settings.VOTER_QUERY_SHORT_CODE}
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.bad_length_nid = get_random_number_string(length=constants.NID_LENGTH + 1)
     self.nid_without_person = get_random_number_string(length=constants.NID_LENGTH)
     self.garbage = u"PING"
     self.citizen = CitizenFactory()
     self.good_nid = unicode(self.citizen.national_id)
Пример #7
0
 def test_max_length(self):
     # Test validation of phone number length
     # Create the form inside the context where we've overridden the regex
     class TestForm(forms.Form):
         phone_number = PhoneNumberFormField()
     exact_length_number = get_random_number_string(settings.MAX_PHONE_NUMBER_LENGTH)
     too_long = get_random_number_string(1 + settings.MAX_PHONE_NUMBER_LENGTH)
     self.assertTrue(TestForm(data=dict(phone_number=exact_length_number)).is_valid())
     self.assertFalse(TestForm(data=dict(phone_number=too_long)).is_valid(),
                      msg="%s should have been too long" % too_long)
Пример #8
0
 def setUp(self):
     # lookup_connections takes any identity and creates connections.
     # It's better than create_connection because it uses 'mockbackend'
     # which keeps track of sent messages.
     self.conn = self.lookup_connections(identities=['111'])[0]
     self.good_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.good_center_id = get_random_number_string(length=constants.CENTER_ID_LENGTH)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
     self.reg_period = RegistrationPeriodFactory(start_time=PAST_DAY, end_time=FUTURE_DAY)
     self.election = ElectionFactory(polling_start_time=PAST_DAY, polling_end_time=FUTURE_DAY)
Пример #9
0
 def setUp(self):
     self.number = get_random_phone_number()
     self.center = RegistrationCenterFactory()
     self.citizen = CitizenFactory()
     self.staffphone = StaffPhone.objects.create(phone_number=self.number,
                                                 registration_center=self.center)
     self.conn = self.create_connection(data={'identity': self.number})
     self.good_nid = self.citizen.national_id
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.short_nid = get_random_number_string(length=constants.NID_LENGTH - 1)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
 def setUp(self):
     self.conn = self.create_connection()
     self.fields = {'to_addr': settings.VOTER_QUERY_SHORT_CODE}
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.bad_length_nid = get_random_number_string(
         length=constants.NID_LENGTH + 1)
     self.nid_without_person = get_random_number_string(
         length=constants.NID_LENGTH)
     self.garbage = u"PING"
     self.citizen = CitizenFactory()
     self.good_nid = unicode(self.citizen.national_id)
Пример #11
0
    def test_max_length(self):
        # Test validation of phone number length
        # Create the model inside the context where we've overridden the regex
        class TestModel1(models.Model):
            phone_number = PhoneNumberField()
        exact_length_number = get_random_number_string(settings.MAX_PHONE_NUMBER_LENGTH)
        TestModel1(phone_number=exact_length_number).full_clean()

        too_long = get_random_number_string(1 + settings.MAX_PHONE_NUMBER_LENGTH)
        with self.assertRaises(ValidationError):
            TestModel1(phone_number=too_long).full_clean()
Пример #12
0
 def setUp(self):
     self.number = get_random_phone_number()
     self.center = RegistrationCenterFactory()
     self.citizen = CitizenFactory()
     self.staffphone = StaffPhone.objects.create(
         phone_number=self.number, registration_center=self.center)
     self.conn = self.create_connection(data={'identity': self.number})
     self.good_nid = self.citizen.national_id
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.short_nid = get_random_number_string(length=constants.NID_LENGTH -
                                               1)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
Пример #13
0
 def setUp(self):
     # lookup_connections takes any identity and creates connections.
     # It's better than create_connection because it uses 'mockbackend'
     # which keeps track of sent messages.
     self.conn = self.lookup_connections(identities=['111'])[0]
     self.good_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.good_center_id = get_random_number_string(
         length=constants.CENTER_ID_LENGTH)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
     self.reg_period = RegistrationPeriodFactory(start_time=PAST_DAY,
                                                 end_time=FUTURE_DAY)
     self.election = ElectionFactory(polling_start_time=PAST_DAY,
                                     polling_end_time=FUTURE_DAY)
Пример #14
0
 def setUp(self):
     self.number = "919-999-9999"
     self.center = RegistrationCenterFactory()
     self.conn = self.create_connection(data={'identity': self.number})
     self.citizen = CitizenFactory()
     self.good_nid = self.citizen.national_id
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.short_nid = get_random_number_string(length=constants.NID_LENGTH - 1)
     self.good_center_id = self.center.center_id
     self.bad_center_id = get_random_number_string(length=constants.CENTER_ID_LENGTH)
     self.long_center_id = get_random_number_string(length=constants.CENTER_ID_LENGTH + 1)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
     RegistrationPeriodFactory(start_time=PAST_DAY, end_time=FUTURE_DAY)
Пример #15
0
    def test_max_length(self):
        # Test validation of phone number length
        # Create the model inside the context where we've overridden the regex
        class TestModel1(models.Model):
            phone_number = PhoneNumberField()

        exact_length_number = get_random_number_string(
            settings.MAX_PHONE_NUMBER_LENGTH)
        TestModel1(phone_number=exact_length_number).full_clean()

        too_long = get_random_number_string(1 +
                                            settings.MAX_PHONE_NUMBER_LENGTH)
        with self.assertRaises(ValidationError):
            TestModel1(phone_number=too_long).full_clean()
Пример #16
0
    def test_max_length(self):
        # Test validation of phone number length
        # Create the form inside the context where we've overridden the regex
        class TestForm(forms.Form):
            phone_number = PhoneNumberFormField()

        exact_length_number = get_random_number_string(
            settings.MAX_PHONE_NUMBER_LENGTH)
        too_long = get_random_number_string(1 +
                                            settings.MAX_PHONE_NUMBER_LENGTH)
        self.assertTrue(
            TestForm(data=dict(phone_number=exact_length_number)).is_valid())
        self.assertFalse(TestForm(data=dict(phone_number=too_long)).is_valid(),
                         msg="%s should have been too long" % too_long)
Пример #17
0
 def setUp(self):
     self.number = "919-999-9999"
     self.center = RegistrationCenterFactory()
     self.conn = self.create_connection(data={'identity': self.number})
     self.citizen = CitizenFactory()
     self.good_nid = self.citizen.national_id
     self.bad_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.short_nid = get_random_number_string(length=constants.NID_LENGTH -
                                               1)
     self.good_center_id = self.center.center_id
     self.bad_center_id = get_random_number_string(
         length=constants.CENTER_ID_LENGTH)
     self.long_center_id = get_random_number_string(
         length=constants.CENTER_ID_LENGTH + 1)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
     RegistrationPeriodFactory(start_time=PAST_DAY, end_time=FUTURE_DAY)
Пример #18
0
 def setUp(self):
     self.conn = self.lookup_connections(identities='111')[0]
     self.good_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
     self.msg = u"%s" % (self.good_nid)
     self.election = ElectionFactory(polling_start_time=PAST_DAY,
                                     polling_end_time=FUTURE_DAY)
Пример #19
0
 def setUp(self):
     # create an approved Batch
     self.batch = BatchFactory(status=Batch.APPROVED)
     # add message to batch
     self.bulk_msg = BulkMessageFactory(
         batch=self.batch,
         phone_number=get_random_number_string(),
         message=u'.نآسف، مرحلة التسجيل عن طريق الرسائل النصية ليست متاحة',
         sms=None)
Пример #20
0
 def setUp(self):
     # create an approved Batch
     self.batch = BatchFactory(status=Batch.APPROVED)
     # add message to batch
     self.bulk_msg = BulkMessageFactory(
         batch=self.batch,
         phone_number=get_random_number_string(),
         message=u'.نآسف، مرحلة التسجيل عن طريق الرسائل النصية ليست متاحة',
         sms=None
     )
Пример #21
0
def generate_random_almadar_number():
    # 218-91xxxxxxx
    return '21891' + get_random_number_string(length=7)
Пример #22
0
    def test_new_logic_rename_me(self):
        phone1 = get_random_number_string(length=10)
        phone2 = get_random_number_string(length=10)
        nid1 = self.good_nid
        ppc1 = self.good_center_id
        ppc2 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        ppc3 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        ppc4 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        ppc5 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        CitizenFactory(national_id=nid1)
        RegistrationCenterFactory(center_id=ppc1)
        RegistrationCenterFactory(center_id=ppc2)
        RegistrationCenterFactory(center_id=ppc3)
        RegistrationCenterFactory(center_id=ppc4)
        RegistrationCenterFactory(center_id=ppc5)
        # Each item in the test_data array is one test.
        # Each test contains one or more steps.
        # Each step contains the phone we receive a message from, the
        # registration center code in that message, the expected response,
        # and the expected registration state after that message.
        # All messages are for the same NID.
        # After each test item, the registrations are reset (deleted).

        # MSG1: you are registered, use same phone to change
        # MSG4: only one more time
        # MSG5: that was your last time

        test_data = [
            # Repeat the same registration from the same phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
            ],
            # Keep trying to change your registration from the same phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc2, constants.MESSAGE_1,
                 ppc2),  # one change is okay
                (phone1, ppc3, constants.MESSAGE_4,
                 ppc3),  # twice is okay but only one left
                (phone1, ppc4, constants.MESSAGE_5,
                 ppc4),  # three is okay but last time
                (phone1, ppc3, constants.MESSAGE_6, ppc4),  # too many, sorry
                (phone1, ppc5, constants.MESSAGE_6, ppc4),  # still too many
            ],
            # Repeat the same registration from a different phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc1, constants.MESSAGE_7, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc1, constants.MESSAGE_7, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc1, constants.MESSAGE_7, ppc1),
            ],
            # Try to change registration from a different phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc2, constants.MESSAGE_2, ppc1),  # sorry charlie
                # then from the original phone
                (phone1, ppc2, constants.MESSAGE_1, ppc2
                 ),  # that's ok - change 1
                # again from another phone
                (phone2, ppc3, constants.MESSAGE_2, ppc2),
                # back to original phone
                (phone1, ppc3, constants.MESSAGE_4, ppc3),  # change 2 - 1 left
                # try other phone again
                (phone2, ppc4, constants.MESSAGE_2, ppc3),
                # original phone again
                (phone1, ppc2, constants.MESSAGE_5, ppc2
                 ),  # 3rd change is the last
                (phone1, ppc4, constants.MESSAGE_6, ppc2),  # too many, sorry
                (phone1, ppc5, constants.MESSAGE_6, ppc2),  # still too many
                # Once you've used up your changes, even sending your current
                # registration results in message 6
                (phone1, ppc2, constants.MESSAGE_6, ppc2),
            ],
            # After changing the registration, the repeat count is reset
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),  # 2nd time - msg 1
                (phone1, ppc1, constants.MESSAGE_1,
                 ppc1),  # 3rd time - msg 1 (enhanced)
                (phone1, ppc2, constants.MESSAGE_1,
                 ppc2),  # change #1 reg - reset counter
                (phone1, ppc2, constants.MESSAGE_1,
                 ppc2),  # 2nd time, same data as #1 change
                (phone1, ppc2, constants.MESSAGE_1,
                 ppc2),  # 3rd time, same data as #1 change
                (phone1, ppc3, constants.MESSAGE_4,
                 ppc3),  # change reg - reset counter
                (phone1, ppc2, constants.MESSAGE_5, ppc2),  # final change
                (phone1, ppc2, constants.MESSAGE_6,
                 ppc2),  # no more changes, always 6
            ],
        ]

        for one_test in test_data:
            # Reset state
            Registration.objects.unfiltered().delete()
            for from_phone, center_id, expected_response, expected_center_id in one_test:
                text = "%s*%s" % (nid1, center_id)
                conn = self.lookup_connections(identities=[from_phone])[0]
                self.receive(text, conn, fields=self.fields)

                # Check the response
                self.assertEqual(expected_response,
                                 self.get_last_response_code())
                # Check the state
                reg = Registration.objects.get(citizen__national_id=nid1)
                self.assertEqual(int(expected_center_id),
                                 reg.registration_center.center_id)
Пример #23
0
 def test_from_shortcode_validation(self):
     msg = BulkMessageFactory()
     msg.from_shortcode = get_random_number_string(length=5)
     with self.assertRaisesRegexp(ValidationError, 'Invalid shortcode'):
         msg.full_clean()
Пример #24
0
    def test_new_logic_rename_me(self):
        phone1 = get_random_number_string(length=10)
        phone2 = get_random_number_string(length=10)
        nid1 = self.good_nid
        ppc1 = self.good_center_id
        ppc2 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        ppc3 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        ppc4 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        ppc5 = get_random_number_string(length=constants.CENTER_ID_LENGTH)
        CitizenFactory(national_id=nid1)
        RegistrationCenterFactory(center_id=ppc1)
        RegistrationCenterFactory(center_id=ppc2)
        RegistrationCenterFactory(center_id=ppc3)
        RegistrationCenterFactory(center_id=ppc4)
        RegistrationCenterFactory(center_id=ppc5)
        # Each item in the test_data array is one test.
        # Each test contains one or more steps.
        # Each step contains the phone we receive a message from, the
        # registration center code in that message, the expected response,
        # and the expected registration state after that message.
        # All messages are for the same NID.
        # After each test item, the registrations are reset (deleted).

        # MSG1: you are registered, use same phone to change
        # MSG4: only one more time
        # MSG5: that was your last time

        test_data = [
            # Repeat the same registration from the same phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
            ],
            # Keep trying to change your registration from the same phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc2, constants.MESSAGE_1, ppc2),  # one change is okay
                (phone1, ppc3, constants.MESSAGE_4, ppc3),  # twice is okay but only one left
                (phone1, ppc4, constants.MESSAGE_5, ppc4),  # three is okay but last time
                (phone1, ppc3, constants.MESSAGE_6, ppc4),  # too many, sorry
                (phone1, ppc5, constants.MESSAGE_6, ppc4),  # still too many
            ],
            # Repeat the same registration from a different phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc1, constants.MESSAGE_7, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc1, constants.MESSAGE_7, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc1, constants.MESSAGE_7, ppc1),
            ],
            # Try to change registration from a different phone
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone2, ppc2, constants.MESSAGE_2, ppc1),  # sorry charlie
                # then from the original phone
                (phone1, ppc2, constants.MESSAGE_1, ppc2),  # that's ok - change 1
                # again from another phone
                (phone2, ppc3, constants.MESSAGE_2, ppc2),
                # back to original phone
                (phone1, ppc3, constants.MESSAGE_4, ppc3),  # change 2 - 1 left
                # try other phone again
                (phone2, ppc4, constants.MESSAGE_2, ppc3),
                # original phone again
                (phone1, ppc2, constants.MESSAGE_5, ppc2),  # 3rd change is the last
                (phone1, ppc4, constants.MESSAGE_6, ppc2),  # too many, sorry
                (phone1, ppc5, constants.MESSAGE_6, ppc2),  # still too many
                # Once you've used up your changes, even sending your current
                # registration results in message 6
                (phone1, ppc2, constants.MESSAGE_6, ppc2),
            ],
            # After changing the registration, the repeat count is reset
            [
                (phone1, ppc1, constants.MESSAGE_1, ppc1),
                (phone1, ppc1, constants.MESSAGE_1, ppc1),  # 2nd time - msg 1
                (phone1, ppc1, constants.MESSAGE_1, ppc1),  # 3rd time - msg 1 (enhanced)
                (phone1, ppc2, constants.MESSAGE_1, ppc2),   # change #1 reg - reset counter
                (phone1, ppc2, constants.MESSAGE_1, ppc2),  # 2nd time, same data as #1 change
                (phone1, ppc2, constants.MESSAGE_1, ppc2),  # 3rd time, same data as #1 change
                (phone1, ppc3, constants.MESSAGE_4, ppc3),   # change reg - reset counter
                (phone1, ppc2, constants.MESSAGE_5, ppc2),  # final change
                (phone1, ppc2, constants.MESSAGE_6, ppc2),   # no more changes, always 6
            ],
        ]

        for one_test in test_data:
            # Reset state
            Registration.objects.unfiltered().delete()
            for from_phone, center_id, expected_response, expected_center_id in one_test:
                text = "%s*%s" % (nid1, center_id)
                conn = self.lookup_connections(identities=[from_phone])[0]
                self.receive(text, conn, fields=self.fields)

                # Check the response
                self.assertEqual(expected_response, self.get_last_response_code())
                # Check the state
                reg = Registration.objects.get(citizen__national_id=nid1)
                self.assertEqual(int(expected_center_id), reg.registration_center.center_id)
Пример #25
0
 def setUp(self):
     self.conn = self.lookup_connections(identities='111')[0]
     self.good_nid = get_random_number_string(length=constants.NID_LENGTH)
     self.fields = {'to_addr': settings.REGISTRATION_SHORT_CODE}
     self.msg = u"%s" % (self.good_nid)
     self.election = ElectionFactory(polling_start_time=PAST_DAY, polling_end_time=FUTURE_DAY)
Пример #26
0
 def setUp(self):
     self.citizen = CitizenFactory()
     self.good_nid = self.citizen.national_id
     self.bad_nid = long(get_random_number_string(length=constants.NID_LENGTH))
     self.nid_without_citizen = long(get_random_number_string(length=constants.NID_LENGTH))
     self.sms = SMSFactory()
Пример #27
0
 def test_from_shortcode_validation(self):
     msg = BulkMessageFactory()
     msg.from_shortcode = get_random_number_string(length=5)
     with self.assertRaisesRegexp(ValidationError, 'Invalid shortcode'):
         msg.full_clean()
Пример #28
0
def generate_random_thuraya_number():
    return '88216' + get_random_number_string(length=8)
Пример #29
0
def generate_random_libyana_number():
    # 218-92xxxxxx
    # 218-94xxxxxx
    return '2189' + random.choice(['2', '4'
                                   ]) + get_random_number_string(length=7)
Пример #30
0
def generate_random_thuraya_number():
    return '88216' + get_random_number_string(length=8)
Пример #31
0
def generate_random_libyana_number():
    # 218-92xxxxxx
    # 218-94xxxxxx
    return '2189' + random.choice(['2', '4']) + get_random_number_string(length=7)
Пример #32
0
def generate_random_almadar_number():
    # 218-91xxxxxxx
    return '21891' + get_random_number_string(length=7)