Beispiel #1
0
    def get(self):

        parser = reqparse.RequestParser()
        parser.add_argument('n', type=int, help='n must be an int')
        args = parser.parse_args()
        fibout = list(fibgen.gen(args['n']))
 
        return jsonify(fibonacci_sequence = fibout) 
Beispiel #2
0
def test_num_0_list():
    fibout = fibgen.gen(0)
    assert isinstance(fibout, list)
Beispiel #3
0
def test_nums_correct_to_25():
    fibout = fibgen.gen(25)
    fibseq = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368]
    assert cmp(fibout, fibseq) == 0
Beispiel #4
0
def test_non_natural_number():
    fibout = fibgen.gen(-1)
    assert 'error: num must be natural number' in fibout
Beispiel #5
0
def test_num_2_val():
    fibout = fibgen.gen(2)
    fibseq = [0, 1]
    assert cmp(fibout, fibseq) == 0
Beispiel #6
0
def test_num_1_val():
    fibout = fibgen.gen(1)
    assert 0 in fibout
Beispiel #7
0
def test_num_0_val():
    fibout = fibgen.gen(0)
    assert 'nil' in fibout