import os
import osgtest.library.core as core
import unittest

class TestStartCondor(unittest.TestCase):

    def test_01_start_condor(self):
        core.config['condor.lockfile'] = '/var/lock/subsys/condor_master'
        core.state['condor.started-service'] = False
        core.state['condor.running-service'] = False

        if core.missing_rpm('condor'):
            return
        if os.path.exists(core.config['condor.lockfile']):
            core.state['condor.running-service'] = True
            core.skip('apparently running')
            return

        command = ('service', 'condor', 'start')
        stdout, _, fail = core.check_system(command, 'Start Condor')
        self.assert_(stdout.find('error') == -1, fail)
        self.assert_(os.path.exists(core.config['condor.lockfile']),
                     'Condor run lock file missing')
        core.state['condor.started-service'] = True
        core.state['condor.running-service'] = True

import os
from osgtest.library import core, osgunittest
import unittest

class TestStartCondor(osgunittest.OSGTestCase):

    def test_01_start_condor(self):
        core.config['condor.lockfile'] = '/var/lock/subsys/condor_master'
        core.state['condor.started-service'] = False
        core.state['condor.running-service'] = False

        core.skip_ok_unless_installed('condor')
        if os.path.exists(core.config['condor.lockfile']):
            core.state['condor.running-service'] = True
            self.skip_ok('already running')
            
        command = ('service', 'condor', 'start')
        stdout, _, fail = core.check_system(command, 'Start Condor')
        self.assert_(stdout.find('error') == -1, fail)
        self.assert_(os.path.exists(core.config['condor.lockfile']),
                     'Condor run lock file missing')
        core.state['condor.started-service'] = True
        core.state['condor.running-service'] = True

Update 10_condor to use OkSkip functionality
Update 10_condor to use OkSkip functionality

git-svn-id: 884a03e47e2adb735d896e55bb5ad6bc3421ba19@16522 4e558342-562e-0410-864c-e07659590f8c

  import os
- import osgtest.library.core as core
+ from osgtest.library import core, osgunittest
  import unittest
  
- class TestStartCondor(unittest.TestCase):
+ class TestStartCondor(osgunittest.OSGTestCase):
  
      def test_01_start_condor(self):
          core.config['condor.lockfile'] = '/var/lock/subsys/condor_master'
          core.state['condor.started-service'] = False
          core.state['condor.running-service'] = False
  
+         core.skip_ok_unless_installed('condor')
-         if core.missing_rpm('condor'):
-             return
          if os.path.exists(core.config['condor.lockfile']):
              core.state['condor.running-service'] = True
-             core.skip('apparently running')
+             self.skip_ok('already running')
-             return
+             
- 
          command = ('service', 'condor', 'start')
          stdout, _, fail = core.check_system(command, 'Start Condor')
          self.assert_(stdout.find('error') == -1, fail)
          self.assert_(os.path.exists(core.config['condor.lockfile']),
                       'Condor run lock file missing')
          core.state['condor.started-service'] = True
          core.state['condor.running-service'] = True
  
Update 10_condor to use OkSkip functionality
## Code Before:
import os
import osgtest.library.core as core
import unittest

class TestStartCondor(unittest.TestCase):

    def test_01_start_condor(self):
        core.config['condor.lockfile'] = '/var/lock/subsys/condor_master'
        core.state['condor.started-service'] = False
        core.state['condor.running-service'] = False

        if core.missing_rpm('condor'):
            return
        if os.path.exists(core.config['condor.lockfile']):
            core.state['condor.running-service'] = True
            core.skip('apparently running')
            return

        command = ('service', 'condor', 'start')
        stdout, _, fail = core.check_system(command, 'Start Condor')
        self.assert_(stdout.find('error') == -1, fail)
        self.assert_(os.path.exists(core.config['condor.lockfile']),
                     'Condor run lock file missing')
        core.state['condor.started-service'] = True
        core.state['condor.running-service'] = True

## Instruction:
Update 10_condor to use OkSkip functionality
## Code After:
import os
from osgtest.library import core, osgunittest
import unittest

class TestStartCondor(osgunittest.OSGTestCase):

    def test_01_start_condor(self):
        core.config['condor.lockfile'] = '/var/lock/subsys/condor_master'
        core.state['condor.started-service'] = False
        core.state['condor.running-service'] = False

        core.skip_ok_unless_installed('condor')
        if os.path.exists(core.config['condor.lockfile']):
            core.state['condor.running-service'] = True
            self.skip_ok('already running')
            
        command = ('service', 'condor', 'start')
        stdout, _, fail = core.check_system(command, 'Start Condor')
        self.assert_(stdout.find('error') == -1, fail)
        self.assert_(os.path.exists(core.config['condor.lockfile']),
                     'Condor run lock file missing')
        core.state['condor.started-service'] = True
        core.state['condor.running-service'] = True
