Example #1
0
    def test_validation_correct(self):
        data = {'from': '1234567', 'to': '9876543', 'text': 'ABC'}

        raised = False
        try:
            validate(data)
        except ValueError:
            raised = True
        self.assertFalse(raised)
Example #2
0
    def post(self):
        message = ''
        error = ''

        data = request.get_json() or {}
        logger.info('Input for outbound sms: %s' % data)

        try:
            validate(data)
            OutboundProcessor(data).process()
            message = 'outbound sms is ok'
        except Exception as e:
            error = str(e) or 'unknown failure'
            logger.error(error)

        return dict(message=message, error=error)
Example #3
0
 def test_validation_text_missing(self):
     data = {'from': '1234567', 'to': '9876543'}
     with self.assertRaises(ValueError):
         validate(data)
Example #4
0
 def test_validation_to_missing(self):
     data = {'from': '1234567', 'text': 'ABC'}
     with self.assertRaises(ValueError):
         validate(data)
Example #5
0
 def test_validation_to_incorrect(self):
     data = {'from': '1234567', 'to': '98765', 'text': 'ABC'}
     with self.assertRaises(ValueError):
         validate(data)
Example #6
0
 def test_validation_from_missing(self):
     data = {'to': '9876543', 'text': 'ABC'}
     with self.assertRaises(ValueError):
         validate(data)