def test_two_runners(): lock = 'LOCK.tmp' config_path = 'config/wombat.yml' config_name = config_path.replace('config/', '') args = [config_name] runner1 = BuildConnectorRunner(args) assert runner1.acquireLock() assert os.path.isfile(lock) assert os.path.abspath(lock) == "%s/%s" % (os.getcwd(), lock) runner2 = BuildConnectorRunner(args) expectedErrPattern = "Simultaneous processes for this connector are prohibited" with pytest.raises(Exception) as excinfo: runner2.acquireLock() actualErrVerbiage = excinfo.value.args[0] assert re.search(expectedErrPattern, actualErrVerbiage) is not None runner1.releaseLock() assert not os.path.isfile(lock)
def test_lock(): lock = 'LOCK.tmp' config_path = 'config/wombat.yml' config_name = config_path.replace('config/', '') args = [config_name] runner = BuildConnectorRunner(args) assert runner.acquireLock() assert os.path.isfile(lock) assert os.path.abspath(lock) == "%s/%s" % (os.getcwd(), lock) runner.releaseLock() assert not os.path.isfile(lock)