Belle II Software
release-08-01-10
test_validationfunctions.py
1
#!/usr/bin/env python3
2
3
10
11
import
unittest
12
import
os
13
import
validationfunctions
14
import
tempfile
15
16
call_iteration = 0
17
18
19
class
ValidationFunctionstTest
(unittest.TestCase):
20
21
"""
22
Various test cases for the validation utility functions
23
"""
24
25
def
test_git_hash
(self):
26
"""
27
Test if the extraction of the git hash works and if not, if the
28
functions returns the expected result
29
"""
30
31
# fixme: disabled for now
32
# test disabled for now, until a way to run this properly on the
33
# build bot can be found
34
return
35
# noinspection PyUnreachableCode
36
37
cwd = os.getcwd()
38
39
with
tempfile.TemporaryDirectory()
as
td:
40
# switch to this folder
41
os.chdir(str(td))
42
ret =
validationfunctions.get_compact_git_hash
(os.getcwd())
43
self.assertTrue(ret
is
None
)
44
45
os.chdir(cwd)
46
47
# in the source folder, we should get a sensible output
48
local_dir = os.environ.get(
"BELLE2_LOCAL_DIR"
,
None
)
49
if
local_dir:
50
ret =
validationfunctions.get_compact_git_hash
(local_dir)
51
self.assertTrue(ret
is
not
None
)
52
print(f
"This source code has git hash {ret}"
)
53
54
55
if
__name__ ==
"__main__"
:
56
unittest.main()
test_validationfunctions.ValidationFunctionstTest
Definition:
test_validationfunctions.py:19
test_validationfunctions.ValidationFunctionstTest.test_git_hash
def test_git_hash(self)
Definition:
test_validationfunctions.py:25
validationfunctions.get_compact_git_hash
Optional[str] get_compact_git_hash(str repo_folder)
Definition:
validationfunctions.py:53
validation
tests
test_validationfunctions.py
Generated on Mon Sep 23 2024 14:07:13 for Belle II Software by
1.9.1