# Path: seal/lib/mr/test_utils.py
# class map_context(object):
# 
#   def __init__(self, jc, input_split):
#     self.job_conf = jc
#     self.input_split = input_split
#     self.counters = {}
#     self.emitted = {}
#     self.status_messages = []
#     self._input_key = None
#     self._input_value = None
# 
#   def getJobConf(self):
#     return self.job_conf
# 
#   def getInputSplit(self):
#     return self.input_split
# 
#   def getInputKey(self):
#     return self._input_key
# 
#   def getInputValue(self):
#     return self._input_value
# 
#   def getCounter(self, group, name):
#     k = '%s:%s' % (group, name)
#     self.counters[k] = 0
#     return k
# 
#   def incrementCounter(self, counter, amount):
#     self.counters[counter] += amount
# 
#   def emit(self, k, v):
#     if not isinstance(k, str):
#       raise TypeError("key must be a string (it's a %s)" % type(k))
#     if not isinstance(v, str):
#       raise TypeError("value must be a string (it's a %s)" % type(v))
# 
#     if not self.emitted.has_key(k):
#       self.emitted[k] = []
#     self.emitted[k].append(v)
# 
#   def progress(self):
#     pass
# 
#   def setStatus(self, status):
#     self.status_messages.append(status)
# 
#   # for compatibility with pydoop 1
#   @property
#   def key(self):
#     return self._input_key
# 
#   @property
#   def value(self):
#     return self._input_value
# 
#   def set_input_key(self, k):
#     self._input_key = k
# 
#   def set_input_value(self, v):
#     self._input_value = v
# 
# class SavingLogger(object):
#     DEBUG = 50
#     INFO = 40
#     WARNING = 30
#     ERROR = 20
#     CRITICAL = 10
# 
#     def __init__(self):
#         self.output = StringIO.StringIO()
#         self.log_level = type(self).DEBUG
# 
#     def contents(self):
#         return self.output.getvalue()
# 
#     def debug(self, *args):
#         if self.log_level >= type(self).DEBUG:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def info(self, *args):
#         if self.log_level >= type(self).INFO:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def warning(self, *args):
#         if self.log_level >= type(self).WARNING:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def error(self, *args):
#         if self.log_level >= type(self).ERROR:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def critical(self, *args):
#         if self.log_level >= type(self).CRITICAL:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")


import re
import time
import unittest
from seal.lib.mr.hadoop_event_monitor import *
from seal.lib.mr.test_utils import map_context, SavingLogger
        self.assertFalse( self.monitor.has_counter("test_has_counter") )
        self.monitor.count("test_has_counter")
        self.assertTrue( self.monitor.has_counter("test_has_counter") )
        self.assertFalse( self.monitor.has_counter("other_counter") )
        self.monitor.add_counter("other_counter")
        self.assertTrue( self.monitor.has_counter("other_counter") )

    def test_new_status(self):
        self.assertEqual(0, len(self.map_ctx.status_messages))
        self.monitor.new_status("test_new_status")
        self.assertEqual(1, len(self.map_ctx.status_messages))
        self.assertEqual("test_new_status", self.map_ctx.status_messages[-1])
        self.assertEqual("test_new_status\n", self.logger.contents())

    def test_new_status_lower_log_level(self):
        self.logger.log_level = SavingLogger.ERROR
        self.assertEqual(0, len(self.map_ctx.status_messages))
        self.monitor.new_status("test_new_status")
        self.assertEqual(1, len(self.map_ctx.status_messages))
        self.assertEqual("test_new_status", self.map_ctx.status_messages[-1])
        self.assertEqual("", self.logger.contents())

    def test_log_debug(self):
        self.logger.log_level = SavingLogger.DEBUG
        self.monitor.log_debug("debug")
        self.assertEqual("debug\n", self.logger.contents())
        self.monitor.log_info("info")
        self.assertEqual("debug\ninfo\n", self.logger.contents())

    def test_log_info(self):

# Path: seal/lib/mr/test_utils.py
# class map_context(object):
# 
#   def __init__(self, jc, input_split):
#     self.job_conf = jc
#     self.input_split = input_split
#     self.counters = {}
#     self.emitted = {}
#     self.status_messages = []
#     self._input_key = None
#     self._input_value = None
# 
#   def getJobConf(self):
#     return self.job_conf
# 
#   def getInputSplit(self):
#     return self.input_split
# 
#   def getInputKey(self):
#     return self._input_key
# 
#   def getInputValue(self):
#     return self._input_value
# 
#   def getCounter(self, group, name):
#     k = '%s:%s' % (group, name)
#     self.counters[k] = 0
#     return k
# 
#   def incrementCounter(self, counter, amount):
#     self.counters[counter] += amount
# 
#   def emit(self, k, v):
#     if not isinstance(k, str):
#       raise TypeError("key must be a string (it's a %s)" % type(k))
#     if not isinstance(v, str):
#       raise TypeError("value must be a string (it's a %s)" % type(v))
# 
#     if not self.emitted.has_key(k):
#       self.emitted[k] = []
#     self.emitted[k].append(v)
# 
#   def progress(self):
#     pass
# 
#   def setStatus(self, status):
#     self.status_messages.append(status)
# 
#   # for compatibility with pydoop 1
#   @property
#   def key(self):
#     return self._input_key
# 
#   @property
#   def value(self):
#     return self._input_value
# 
#   def set_input_key(self, k):
#     self._input_key = k
# 
#   def set_input_value(self, v):
#     self._input_value = v
# 
# class SavingLogger(object):
#     DEBUG = 50
#     INFO = 40
#     WARNING = 30
#     ERROR = 20
#     CRITICAL = 10
# 
#     def __init__(self):
#         self.output = StringIO.StringIO()
#         self.log_level = type(self).DEBUG
# 
#     def contents(self):
#         return self.output.getvalue()
# 
#     def debug(self, *args):
#         if self.log_level >= type(self).DEBUG:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def info(self, *args):
#         if self.log_level >= type(self).INFO:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def warning(self, *args):
#         if self.log_level >= type(self).WARNING:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def error(self, *args):
#         if self.log_level >= type(self).ERROR:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")
# 
#     def critical(self, *args):
#         if self.log_level >= type(self).CRITICAL:
#             self.output.write(' '.join(map(str, args)))
#             self.output.write("\n")


# Path: tests/tseal/lib/mr/test_hadoop_event_monitor.py
import re
import time
import unittest
from seal.lib.mr.hadoop_event_monitor import *
from seal.lib.mr.test_utils import map_context, SavingLogger

        self.assertFalse( self.monitor.has_counter("test_has_counter") )
        self.monitor.count("test_has_counter")
        self.assertTrue( self.monitor.has_counter("test_has_counter") )
        self.assertFalse( self.monitor.has_counter("other_counter") )
        self.monitor.add_counter("other_counter")
        self.assertTrue( self.monitor.has_counter("other_counter") )

    def test_new_status(self):
        self.assertEqual(0, len(self.map_ctx.status_messages))
        self.monitor.new_status("test_new_status")
        self.assertEqual(1, len(self.map_ctx.status_messages))
        self.assertEqual("test_new_status", self.map_ctx.status_messages[-1])
        self.assertEqual("test_new_status\n", self.logger.contents())

    def test_new_status_lower_log_level(self):
        self.logger.log_level = SavingLogger.ERROR
        self.assertEqual(0, len(self.map_ctx.status_messages))
        self.monitor.new_status("test_new_status")
        self.assertEqual(1, len(self.map_ctx.status_messages))
        self.assertEqual("test_new_status", self.map_ctx.status_messages[-1])
        self.assertEqual("", self.logger.contents())

    def test_log_debug(self):
        self.logger.log_level = SavingLogger.DEBUG
        self.monitor.log_debug("debug")
        self.assertEqual("debug\n", self.logger.contents())
        self.monitor.log_info("info")
        self.assertEqual("debug\ninfo\n", self.logger.contents())

    def test_log_info(self):

        self.logger.log_level = SavingLogger.INFO