Belle II Software development
test_environmentInformation.py
1
8from unittest import TestCase, main
9try:
10 from unittest.mock import patch, MagicMock
11except ImportError:
12 from unittest.mock import patch, MagicMock
13
14import datetime
15
16from hep_ipython_tools.information import EnvironmentInformation
17
18# @cond internal_test
19
20
21class TestEnvironmentInformation(TestCase):
22
23 def setUp(self):
24 self.patch = patch("hep_ipython_tools.information.datetime")
25 datetime_patch = self.patch.start()
26
27 datetime_patch.now = MagicMock(return_value=datetime.datetime(1999, 11, 12))
28
29 self.information = EnvironmentInformation()
30
31 self.information.externals_version = "Version"
32 self.information.externals_option = "ExternalOption"
33 self.information.option = "Option"
34 self.information.architecture = "Architecture"
35 self.information.release = "Release"
36 self.information.release_folder = "ReleaseFolder"
37
38 def tearDown(self):
39 self.patch.stop()
40
41 def test_str(self):
42 self.information._cached_revision = "Revision"
43
44 string_information = str(self.information)
45 self.assertEqual(string_information.splitlines(), ["externals version: Version",
46 "externals option: ExternalOption",
47 "option: Option",
48 "architecture: Architecture",
49 "release: Release",
50 "release folder: ReleaseFolder",
51 "revision number: Revision",
52 "date: 1999-11-12"])
53
54 def test_repr(self):
55 self.information._cached_revision = "Revision"
56 string_information = str(self.information)
57 repr_information = self.information.__repr__()
58
59 self.assertEqual(repr_information, string_information)
60
61 def test_cached_revision(self):
62 self.information._cached_revision = "Revision"
63
64 self.assertEqual(self.information.revision_number, "Revision")
65
66 def test_new_revision(self):
67
68 self.information.get_current_revision_number = MagicMock(return_value="OtherRevision")
69
70 self.assertEqual(self.information.revision_number, "OtherRevision")
71
72 self.information.get_current_revision_number.assert_called_once_with()
73
74 def test_get_current_revision(self):
75 pass
76
77
78if __name__ == "__main__":
79 main()
80# @endcond
Definition: main.py:1