def test_processFizzbuzzOk(self): ml = FizzBuzzML(int1=3, int2=5, mlimit=15, str1='m3', str2='m5') lc = FizzBuzzLC() compareTo = [ 1, 2, 'm3', 4, 'm5', 'm3', 7, 8, 'm3', 'm5', 11, 'm3', 13, 14, 'm3m5' ] self.assertSequenceEqual(lc.processFizzbuzz(ml), compareTo)
def get(self): """ Computes fizzbuzz algorithm Returns the list of fizzbuzz processed """ fzquery = FizzBuzzML(request.args.get('int1', None, int), request.args.get('int2', None, int), request.args.get('limit', None, int), request.args.get('str1', None, str), request.args.get('str2', None, str)) fzlogic = FizzBuzzLC() success, result, errStr = fzlogic.compute(fzquery) if success: #insert into db fzRq = FizzBuzzRQ() fzRq.insertUsersRequest(fzquery) return {'success': success, 'result': result}, 200 else: return {'success': success, 'error': errStr}, 400
def test_isValidDataKoMlimitLessInt2(self): ml = FizzBuzzML(int1=2, int2=4, mlimit=3, str1='m3', str2='m5') lc = FizzBuzzLC() res, errStr = lc.isValidData(ml) self.assertFalse(res) self.assertIsNotNone(errStr)
def test_isValidDataKoInt2EquInt1(self): ml = FizzBuzzML(int1=1, int2=1, mlimit=1, str1='m3', str2='m5') lc = FizzBuzzLC() res, errStr = lc.isValidData(ml) self.assertFalse(res) self.assertIsNotNone(errStr)
def test_isValidDataOk(self): ml = FizzBuzzML(int1=1, int2=2, mlimit=3, str1='m3', str2='m5') lc = FizzBuzzLC() self.assertTrue(lc.isValidData(ml))
def test_isValidDataKoStr2None(self): ml = FizzBuzzML(int1=2, int2=3, mlimit=10, str1='m3', str2=None) lc = FizzBuzzLC() res, errStr = lc.isValidData(ml) self.assertFalse(res) self.assertIsNotNone(errStr)