Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 951aff2

Browse files
committed
Added more complete test
1 parent e025718 commit 951aff2

3 files changed

Lines changed: 59 additions & 3 deletions

File tree

Integration/Test_UserJobs.py

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
""" Testing the API and a bit more.
2+
It will submit a number of test jobs locally (via runLocal), using the python unittest to assess the results.
3+
Can be automatized.
4+
"""
5+
16
from DIRAC.Core.Base.Script import parseCommandLine
27
parseCommandLine()
38

@@ -15,8 +20,8 @@
1520
cwd = os.path.realpath( '.' )
1621

1722
class UserJobTestCase( unittest.TestCase ):
18-
''' Base class for the UserJob test cases
19-
'''
23+
""" Base class for the UserJob test cases
24+
"""
2025
def setUp( self ):
2126
cleanTestDir()
2227

@@ -25,17 +30,56 @@ def setUp( self ):
2530

2631

2732
class HelloWorldSuccess( UserJobTestCase ):
33+
""" Simplest ever. helloWorld.py just calls 'echo'
34+
"""
35+
def test_execute( self ):
36+
37+
job = Job()
38+
39+
job.setName( "helloWorld-test" )
40+
job.setExecutable( "helloWorld.py" )
41+
res = job.runLocal( self.dirac )
42+
self.assertTrue( res['OK'] )
43+
44+
class HelloWorldPlusSuccess( UserJobTestCase ):
45+
""" Adding quite a lot of calls from the API, for pure test purpose
46+
"""
47+
2848
def test_execute( self ):
2949

3050
job = Job()
3151

3252
job.setName( "helloWorld-test" )
33-
job.setExecutable( "exe-script.py" )
53+
job.setExecutable( "helloWorld.py", arguments = "This is an argument", logFile = "aLogFileForTest.txt" )
54+
job.setBannedSites( ['LCG.SiteA.com', 'DIRAC.SiteB.org'] )
55+
job.setOwner( 'ownerName' )
56+
job.setOwnerGroup( 'ownerGroup' )
57+
job.setName( 'jobName' )
58+
job.setJobGroup( 'jobGroup' )
59+
job.setType( 'jobType' )
60+
job.setDestination( 'DIRAC.someSite.ch' )
61+
job.setCPUTime( 12345 )
62+
job.setLogLevel( 'DEBUG' )
63+
3464
res = job.runLocal( self.dirac )
3565
self.assertTrue( res['OK'] )
3666

67+
68+
# class CatSuccess( UserJobTestCase ):
69+
# def test_execute( self ):
70+
#
71+
# job = Job()
72+
#
73+
# job.setName( "cat-test" )
74+
# job.setExecutable( "cat.py" )
75+
# job.set
76+
# res = job.runLocal( self.dirac )
77+
# self.assertTrue( res['OK'] )
78+
79+
3780
if __name__ == '__main__':
3881
suite = unittest.defaultTestLoader.loadTestsFromTestCase( UserJobTestCase )
3982
suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase( HelloWorldSuccess ) )
83+
suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase( HelloWorldPlusSuccess ) )
4084
testResult = unittest.TextTestRunner( verbosity = 2 ).run( suite )
4185

Integration/cat.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env python
2+
'''Script to run Executable application'''
3+
4+
from os import system, environ, pathsep, getcwd
5+
import sys
6+
7+
# Main
8+
if __name__ == '__main__':
9+
10+
environ['PATH'] = getcwd() + ( pathsep + environ['PATH'] )
11+
12+
sys.exit( system( '''echo Hello World''' ) / 256 )

0 commit comments

Comments
 (0)