def mySum(): if request.method == 'POST': jsonAll=request.get_json() check = checkInput(jsonAll) if(check['failed']): return json.dumps({'FAILED': check['massege']}), check['status'], {'ContentType':'application/json'} firstNum=check["firstNum"] secondNum=check["secondNum"] ans = sum(firstNum,secondNum) return json.dumps({'success': ans}), 200, {'ContentType':'application/json'}
def test_sum_with_carry(self): self.assertEqual(sum([9, 9, 9], [1]), [1, 0, 0, 0]) self.assertEqual(sum([9, 9], [1, 1]), [1, 1, 0])
def test_sum_with_big_number(self): self.assertEqual( sum([1, 2, 3, 4, 5, 6, 7, 8, 9], [1, 2, 3, 4, 5, 6, 7, 8, 9]), [2, 4, 6, 9, 1, 3, 5, 7, 8])
def test_sum(self): self.assertEqual(sum([1, 1, 1], [4, 5, 6]), [5, 6, 7])
def test_sum_with_zero(self): self.assertEqual(sum([9, 9, 9], [0]), [9, 9, 9]) self.assertEqual(sum([0], [1, 1]), [1, 1]) self.assertEqual(sum([0], [0]), [0])