Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
fail-fast: False
matrix:
command:
- pytest
- DIRAC_USE_M2CRYPTO=Yes DIRAC_M2CRYPTO_SPLIT_HANDSHAKE=Yes pytest
- pytest Core/Security/test
- DIRAC_USE_M2CRYPTO=Yes DIRAC_M2CRYPTO_SPLIT_HANDSHAKE=Yes pytest Core/Security/test
- pytest --no-cov
- DIRAC_USE_M2CRYPTO=Yes DIRAC_M2CRYPTO_SPLIT_HANDSHAKE=Yes pytest --no-cov
- pytest --no-cov Core/Security/test
- DIRAC_USE_M2CRYPTO=Yes DIRAC_M2CRYPTO_SPLIT_HANDSHAKE=Yes pytest --no-cov Core/Security/test
- tests/checkDocs.sh
# TODO This should cover more than just tests/CI
# Excluded codes related to sourcing files
Expand Down
67 changes: 23 additions & 44 deletions WorkloadManagementSystem/PilotAgent/test/Test_Pilot.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,33 @@
"""

# imports
import unittest
import json
import os
import sys

if "--no-cov" in sys.argv:
del sys.argv[sys.argv.index('--no-cov')]

from DIRAC.WorkloadManagementSystem.PilotAgent.pilotTools import PilotParams, CommandBase
from DIRAC.WorkloadManagementSystem.PilotAgent.pilotCommands import GetPilotVersion

class PilotTestCase( unittest.TestCase ):
""" Base class for the Agents test cases
"""
def setUp( self ):
self.pp = PilotParams()

def tearDown( self ):
try:
os.remove('pilot.out')
os.remove( 'pilot.json' )
os.remove( 'pilot.json-local' )
except OSError:
pass


class CommandsTestCase( PilotTestCase ):

def test_commandBase(self):
cb = CommandBase(self.pp)
returnCode, _outputData = cb.executeAndGetOutput("ls")
self.assertEqual(returnCode, 0)

def test_GetPilotVersion( self ):

# Now defining a local file for test, and all the necessary parameters
fp = open( 'pilot.json', 'w' )
json.dump( {'TestSetup':{'Version':['v1r1', 'v2r2']}}, fp )
fp.close()
self.pp.setup = 'TestSetup'
self.pp.pilotCFGFileLocation = 'file://%s' % os.getcwd()
gpv = GetPilotVersion( self.pp )
self.assertIsNone( gpv.execute() )
self.assertEqual( gpv.pp.releaseVersion, 'v1r1' )

#############################################################################
# Test Suite run
#############################################################################

if __name__ == '__main__':
suite = unittest.defaultTestLoader.loadTestsFromTestCase( PilotTestCase )
suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase( CommandsTestCase ) )
testResult = unittest.TextTestRunner( verbosity = 2 ).run( suite )

# EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#EOF#
def test_GetPilotVersion():
pp = PilotParams()
# Now defining a local file for test, and all the necessary parameters
fp = open('pilot.json', 'w')
json.dump({'TestSetup': {'Version': ['v1r1', 'v2r2']}}, fp)
fp.close()
pp.setup = 'TestSetup'
pp.pilotCFGFileLocation = 'file://%s' % os.getcwd()
gpv = GetPilotVersion(pp)
result = gpv.execute()
assert result is None
assert gpv.pp.releaseVersion == 'v1r1'


def test_commandBase():
pp = PilotParams()
cb = CommandBase(pp)
returnCode, _outputData = cb.executeAndGetOutput("ls")
assert returnCode == 0