-
Notifications
You must be signed in to change notification settings - Fork 0
/
tests.py
executable file
·47 lines (28 loc) · 1.1 KB
/
tests.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# -*- coding: utf-8 -*-
import unittest
import json
from app import APP, views
class FactorisationTestCase(unittest.TestCase):
def setUp(self):
APP.config["TESTING"] = True
self.app = APP.test_client()
def tearDown(self):
APP.config["TESTING"] = False
def get_factorization(self, number):
"""Метод юнит-теста"""
response = self.app.post(
"/get_factorization/", data=dict(number=number))
data = json.loads(response.data)
return data
def test_get_factorization(self):
"""Тест метода /get_factorization/"""
data = self.get_factorization(34839583)
assert len(data["result"]) > 1
data = self.get_factorization(u"abc")
assert u"Введите натуральное число" in data["result"]
data = self.get_factorization(1)
assert u"Введите натуральное число больше 1" in data["result"]
data = self.get_factorization(5)
assert len(data["result"]) == 1
if __name__ == "__main__":
unittest.main()