8from unittest
import TestCase, main
10 from unittest.mock
import patch, MagicMock
12 from unittest.mock
import patch, MagicMock
21class TestEnvironmentInformation(TestCase):
24 self.patch = patch(
"hep_ipython_tools.information.datetime")
25 datetime_patch = self.patch.start()
27 datetime_patch.now = MagicMock(return_value=datetime.datetime(1999, 11, 12))
29 self.information = EnvironmentInformation()
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"
42 self.information._cached_revision =
"Revision"
44 string_information = str(self.information)
45 self.assertEqual(string_information.splitlines(), [
"externals version: Version",
46 "externals option: ExternalOption",
48 "architecture: Architecture",
50 "release folder: ReleaseFolder",
51 "revision number: Revision",
55 self.information._cached_revision =
"Revision"
56 string_information = str(self.information)
57 repr_information = self.information.__repr__()
59 self.assertEqual(repr_information, string_information)
61 def test_cached_revision(self):
62 self.information._cached_revision =
"Revision"
64 self.assertEqual(self.information.revision_number,
"Revision")
66 def test_new_revision(self):
68 self.information.get_current_revision_number = MagicMock(return_value=
"OtherRevision")
70 self.assertEqual(self.information.revision_number,
"OtherRevision")
72 self.information.get_current_revision_number.assert_called_once_with()
74 def test_get_current_revision(self):
78if __name__ ==
"__main__":