def test_validation_correct(self): data = {'from': '1234567', 'to': '9876543', 'text': 'ABC'} raised = False try: validate(data) except ValueError: raised = True self.assertFalse(raised)
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)
def test_validation_text_missing(self): data = {'from': '1234567', 'to': '9876543'} with self.assertRaises(ValueError): validate(data)
def test_validation_to_missing(self): data = {'from': '1234567', 'text': 'ABC'} with self.assertRaises(ValueError): validate(data)
def test_validation_to_incorrect(self): data = {'from': '1234567', 'to': '98765', 'text': 'ABC'} with self.assertRaises(ValueError): validate(data)
def test_validation_from_missing(self): data = {'to': '9876543', 'text': 'ABC'} with self.assertRaises(ValueError): validate(data)