-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_corona_plot.py
64 lines (38 loc) · 2.02 KB
/
test_corona_plot.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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python3.8
import unittest
import warnings
import corona.corona_virus as cv
import corona.corona_plot as cp
class TestCoronaPlot(unittest.TestCase):
@classmethod
def setUpClass(cls):
with warnings.catch_warnings():
warnings.filterwarnings("ignore", category=DeprecationWarning)
corona_info = cv.get_countries_info()
correct_info = cv.info_correction(corona_info)
cls.sort_info = cv.sort_informations(correct_info)
cls.file_path = cv.create_file_path()
cv.write_in_csv(cls.sort_info)
def test_get_total_data(self):
total_data = cp.get_total_data(self.file_path)
self.assertIsInstance(total_data, tuple)
self.assertIsInstance(total_data[0], dict)
self.assertIsInstance(total_data[1], dict)
def test_plot_data(self):
total_case, total_death = cp.get_total_data(self.file_path)
cp.plot_data(total_case, total_death)
cp.plot_data(total_case, total_death, save_svg_img_in_path=self.file_path)
cp.plot_data(total_case, total_death, save_svg_img_in_path=self.file_path + ".svg")
with self.assertRaises(TypeError):
cp.plot_data(total_case, total_death, save_svg_img_in_path=True)
cp.plot_data(total_case, total_death, save_svg_img_in_path=False)
cp.plot_data(total_case, total_death, save_svg_img_in_path=12)
cp.plot_data(total_case, total_death, save_svg_img_in_path=12.21)
cp.plot_data(total_case, total_death, save_svg_img_in_path=list())
cp.plot_data(total_case, total_death, save_svg_img_in_path=[1, 2, 3])
cp.plot_data(total_case, total_death, save_svg_img_in_path=dict())
cp.plot_data(total_case, total_death, save_svg_img_in_path={"a": 1, "b": 2, "c": 3})
cp.plot_data(total_case, total_death, save_svg_img_in_path=tuple())
cp.plot_data(total_case, total_death, save_svg_img_in_path=(1, 2, 3))
if __name__ == "__main__":
unittest.main()