Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Colas Pomies
LbNightlyTools
Commits
eb2ac124
Commit
eb2ac124
authored
Apr 14, 2015
by
cpomies
Browse files
Add test for CheckReadySlots
parent
881e01dc
Changes
1
Hide whitespace changes
Inline
Side-by-side
python/LbNightlyTools/tests/test_ready_slots_script.py
0 → 100644
View file @
eb2ac124
##############################################################################
# (c) Copyright 2013 CERN #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
# Uncomment to disable the tests.
#__test__ = False
__author__
=
'Colas Pomies <colas.pomies@cern.ch>'
from
LbNightlyTools
import
CheckReadySlots
import
os
import
re
from
sets
import
Set
from
os.path
import
normpath
,
join
from
LbNightlyTools.tests.utils
import
TemporaryDir
_testdata
=
normpath
(
join
(
*
([
__file__
]
+
[
os
.
pardir
]
*
4
+
[
'testdata'
])))
_env_bk
=
dict
(
os
.
environ
)
def
setup
():
global
_env_bk
_env_bk
=
dict
(
os
.
environ
)
def
teardown
():
global
_env_bk
os
.
environ
.
clear
()
os
.
environ
.
update
(
_env_bk
)
def
test_no_data
():
with
TemporaryDir
(
chdir
=
True
):
retval
=
CheckReadySlots
.
Script
().
run
([
'slot-param-{0}.txt'
])
assert
retval
==
0
assert
len
([
x
for
x
in
os
.
listdir
(
'.'
)
if
re
.
match
(
r
'^slot-param-.*\.txt'
,
x
)])
==
0
def
test_no_file_xml
():
with
TemporaryDir
(
chdir
=
True
):
slots
=
CheckReadySlots
.
Script
().
extractFromXml
(
'configuration.xml'
)
assert
len
(
slots
)
==
0
def
test_no_file_json
():
with
TemporaryDir
(
chdir
=
True
):
slots
=
CheckReadySlots
.
Script
().
extractFromXml
(
'lhcb-*.json'
)
assert
len
(
slots
)
==
0
def
test_no_slot_to_write
():
with
TemporaryDir
(
chdir
=
True
):
CheckReadySlots
.
Script
().
writeFiles
(
Set
(),
'slot-param-{0}.txt'
)
assert
len
([
x
for
x
in
os
.
listdir
(
'.'
)
if
re
.
match
(
r
'^slot-param-.*\.txt'
,
x
)])
==
0
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment