Пример #1
0
    def test_help(self):
        devices = Device.objects.all()
        contributors = Contributor.objects.all()
        nb_devices = len(devices)
        nb_contributors = len(contributors)

        contributor = Contributor(name=self.unregister_test_user_name, email=self.unregister_test_user_email, password=self.unregister_test_user_password)
        contributor.save()
        device = Device(phone_number=self.help_no, contributor=contributor)
        device.save()
                            
        receive_sms(self.help_no, "help")
        devices = Device.objects.all()
        contributors = Contributor.objects.all()
        self.assertEqual(len(devices), nb_devices + 1)
        self.assertEqual(len(contributors), nb_contributors + 1)
Пример #2
0
def create_unknown_user(mobile_number):
    # TODO: Really not sure about this process and how python handles the erros, what happen if an error occurs?
    try:
        contributor = Contributor(name=mobile_number, email=mobile_number + "@feowl.com", status=Contributor.UNKNOWN)
        contributor.save()
        device = Device(category="mobile", phone_number=mobile_number, contributor=contributor)
        device.save()
    except IntegrityError, e:
        msg = e.message
        if msg.find("name") != -1:
            logger.warning("Name already exist. Please use an other one")
            return
        elif msg.find("email") != -1:
            logger.warning("Email already exist. Please use an other one.")
            return
        logger.error("Unkown Error please try later to register")
        return