from pysys.basetest import BaseTest
from apama.correlator import CorrelatorHelper
import os

class PySysTest(BaseTest):
	def execute(self):
		corr = CorrelatorHelper(self, name='correlator')
		corr.start(logfile='correlator.log')
		corr.injectEPL(os.getenv('APAMA_HOME','') + '/monitors/ManagementImpl.mon')
		corr.injectEPL(os.getenv('APAMA_HOME','') + '/monitors/Management.mon')

		corr.injectEPL('../../../src/Assert.mon')

		corr.injectEPL('TestAssertFail.mon')
		self.waitForGrep('correlator.log', 'Removed monitor TestAssertFail')

	def validate(self):
		self.assertGrep('correlator.log', r' (ERROR|WARN) .*', contains=False)

[((149, 190), 'apama.correlator.CorrelatorHelper', 'CorrelatorHelper', (['self'], {'name': '"""correlator"""'}), "(self, name='correlator')\n", (165, 190), False, 'from apama.correlator import CorrelatorHelper\n'), ((247, 274), 'os.getenv', 'os.getenv', (['"""APAMA_HOME"""', '""""""'], {}), "('APAMA_HOME', '')\n", (256, 274), False, 'import os\n'), ((325, 352), 'os.getenv', 'os.getenv', (['"""APAMA_HOME"""', '""""""'], {}), "('APAMA_HOME', '')\n", (334, 352), False, 'import os\n')]