Esempio n. 1
0
 def test_copy_registration_center(self):
     """test that people can't register against a copy center"""
     copy_center = RegistrationCenterFactory()
     copy_center.copy_of = self.center
     copy_center.save()
     # try to register
     result = process_registration_request(
         center_id=copy_center.center_id, national_id=self.citizen.national_id, sms=self.sms
     )
     self.assertEqual(result.message_code, constants.RESPONSE_CENTER_ID_INVALID)
    def test_ensure_copied_center_undeletable(self):
        """Ensure centers that have copies can't be deleted"""
        original = RegistrationCenterFactory()
        copy = RegistrationCenterFactory(copy_of=original)
        center_admin = RegistrationCenterAdmin(RegistrationCenter, admin.site)
        self.assertIn('deleted', center_admin.get_readonly_fields(Mock(), obj=original))

        # However, if the copy is soft deleted, then it's OK to delete the original
        copy.deleted = True
        copy.save()
        center_admin = RegistrationCenterAdmin(RegistrationCenter, admin.site)
        self.assertNotIn('deleted', center_admin.get_readonly_fields(Mock(), obj=original))
Esempio n. 3
0
 def test_copy_registration_center(self):
     """test that people can't register against a copy center"""
     copy_center = RegistrationCenterFactory()
     copy_center.copy_of = self.center
     copy_center.save()
     # try to register
     result = process_registration_request(
         center_id=copy_center.center_id,
         national_id=self.citizen.national_id,
         sms=self.sms)
     self.assertEqual(result.message_code,
                      constants.RESPONSE_CENTER_ID_INVALID)
Esempio n. 4
0
 def test_user_can_change_from_inactivated_center(self):
     # User should be able to change registration center, even if previous center was
     # inactivated.
     # Create a registration and inactivate the center
     citizen = CitizenFactory()
     inactivated_center = RegistrationCenterFactory()
     self.receive("%s %s" % (citizen.national_id, inactivated_center.center_id), self.conn, fields=self.fields)
     inactivated_center.reg_open = False
     inactivated_center.save()
     # User registers at a new center
     new_center = RegistrationCenterFactory()
     self.receive("%s %s" % (citizen.national_id, new_center.center_id), self.conn, fields=self.fields)
     self.assertEqual(constants.MESSAGE_1, self.get_last_response_code())
     new_reg = models.Registration.objects.get(citizen=citizen)
     self.assertEqual(new_reg.registration_center, new_center)
Esempio n. 5
0
 def test_user_can_change_from_inactivated_center(self):
     # User should be able to change registration center, even if previous center was
     # inactivated.
     # Create a registration and inactivate the center
     citizen = CitizenFactory()
     inactivated_center = RegistrationCenterFactory()
     self.receive("%s %s" %
                  (citizen.national_id, inactivated_center.center_id),
                  self.conn,
                  fields=self.fields)
     inactivated_center.reg_open = False
     inactivated_center.save()
     # User registers at a new center
     new_center = RegistrationCenterFactory()
     self.receive("%s %s" % (citizen.national_id, new_center.center_id),
                  self.conn,
                  fields=self.fields)
     self.assertEqual(constants.MESSAGE_1, self.get_last_response_code())
     new_reg = models.Registration.objects.get(citizen=citizen)
     self.assertEqual(new_reg.registration_center, new_center)