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