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)

[((7, 9, 7, 50), 'apama.correlator.CorrelatorHelper', 'CorrelatorHelper', (), '', False, 'from apama.correlator import CorrelatorHelper\n'), ((9, 17, 9, 43), 'os.getenv', 'os.getenv', ({(9, 27, 9, 39): '"""APAMA_HOME"""', (9, 40, 9, 42): '""""""'}, {}), "('APAMA_HOME', '')", False, 'import os\n'), ((10, 17, 10, 43), 'os.getenv', 'os.getenv', ({(10, 27, 10, 39): '"""APAMA_HOME"""', (10, 40, 10, 42): '""""""'}, {}), "('APAMA_HOME', '')", False, 'import os\n')]