class ProcessListSimpleTestCase(unittest.TestCase): """ Test the simple methods of the class that dont need a sane CFG """ def setUp(self): with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=False)): self.prol = ProcessList('myTestProcess.list') def test_constructor(self): import DIRAC with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', return_value=True): empty_process_list = ProcessList('existent_location') self.assertTrue(empty_process_list.cfg.existsKey('Processes')) self.assertTrue(empty_process_list.isOK()) def replace_load(self, _): #pylint: disable=missing-docstring self.createNewSection('myTestSection', 'testComment') self.createNewSection('Processes', 'testProcesses') with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', side_effect=replace_load, autospec=True): other_process_list = ProcessList('existent_location') self.assertTrue(other_process_list.cfg.existsKey('Processes')) self.assertFalse(self.prol.isOK()) def test_addentry(self): self.prol.cfg.createNewSection('Processes') self.prol.cfg.createNewSection('Processes/123') self.prol._addEntry('123', STD_PROC_DICT)
class ProcessListSimpleTestCase( unittest.TestCase ): """ Test the simple methods of the class that dont need a sane CFG """ def setUp( self ): with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=False)): self.prol = ProcessList( 'myTestProcess.list' ) def test_constructor( self ): import DIRAC with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', return_value=True): empty_process_list = ProcessList( 'existent_location' ) self.assertTrue( empty_process_list.cfg.existsKey('Processes') ) self.assertTrue( empty_process_list.isOK() ) def replace_load( self, _ ): #pylint: disable=missing-docstring self.createNewSection( 'myTestSection', 'testComment' ) self.createNewSection( 'Processes', 'testProcesses' ) with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', side_effect=replace_load, autospec=True): other_process_list = ProcessList( 'existent_location' ) self.assertTrue( other_process_list.cfg.existsKey('Processes') ) self.assertFalse( self.prol.isOK() ) def test_addentry( self ): self.prol.cfg.createNewSection( 'Processes' ) self.prol.cfg.createNewSection( 'Processes/123' ) self.prol._addEntry( '123', STD_PROC_DICT )
def test_constructor(self): import DIRAC with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', return_value=True): empty_process_list = ProcessList('existent_location') self.assertTrue(empty_process_list.cfg.existsKey('Processes')) self.assertTrue(empty_process_list.isOK()) def replace_load(self, _): #pylint: disable=missing-docstring self.createNewSection('myTestSection', 'testComment') self.createNewSection('Processes', 'testProcesses') with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', side_effect=replace_load, autospec=True): other_process_list = ProcessList('existent_location') self.assertTrue(other_process_list.cfg.existsKey('Processes')) self.assertFalse(self.prol.isOK())
def test_constructor( self ): import DIRAC with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', return_value=True): empty_process_list = ProcessList( 'existent_location' ) self.assertTrue( empty_process_list.cfg.existsKey('Processes') ) self.assertTrue( empty_process_list.isOK() ) def replace_load( self, _ ): #pylint: disable=missing-docstring self.createNewSection( 'myTestSection', 'testComment' ) self.createNewSection( 'Processes', 'testProcesses' ) with patch('%s.os.path.exists' % MODULE_NAME, new=Mock(return_value=True)), \ patch.object(DIRAC.Core.Utilities.CFG.CFG, 'loadFromFile', side_effect=replace_load, autospec=True): other_process_list = ProcessList( 'existent_location' ) self.assertTrue( other_process_list.cfg.existsKey('Processes') ) self.assertFalse( self.prol.isOK() )