示例#1
0
    def test_argprepender(self):
        class Wrapped(object):
            def callme(self, project, client, execution, param1):
                return (project, client, execution, param1)

        execution = ArgPrepender(Wrapped(), "aproject", "aclient",
                                 "anexecution")
        self.assertEqual(execution.callme("woo"),
                         ("aproject", "aclient", "anexecution", "woo"))
示例#2
0
 def test_executionStarts_whenBadClient(self):
     s = Logger("fixture")
     s.createServer()
     s.createProject("myproject")
     e = ArgPrepender(s, "myproject", "badclient", "20130301-132313")
     try:
         e.executionStarts(timestamp="2013-03-01 13:23:13", changelog=[])
         self.fail("Exception expected")
     except ClientNotFound, e:
         self.assertEqual(e.message, "Client not found 'badclient'")
示例#3
0
	def test_argprepender(self) :

		class Wrapped(object) :
			def callme(self, project, client, execution, param1) :
					return (project, client, execution, param1)

		execution = ArgPrepender(Wrapped(),
			"aproject", "aclient", "anexecution")
		self.assertEqual(
				execution.callme("woo"),
				("aproject", "aclient", "anexecution","woo"))
示例#4
0
	def test_executionStarts_whenBadClient(self) :
		s = Logger("fixture")
		s.createServer()
		s.createProject("myproject")
		e = ArgPrepender(s, "myproject","badclient","20130301-132313")
		try :
			e.executionStarts(
				timestamp="2013-03-01 13:23:13",
				changelog=[])
			self.fail("Exception expected")
		except ClientNotFound, e:
			self.assertEqual(e.message, "Client not found 'badclient'")
示例#5
0
	def setUpExecution(self, client, name, ok=True, running=False) :
		s = Logger("fixture")
		e = ArgPrepender(s, "myproject", client, name)
		timestamp = "{0:%Y-%m-%d %H:%M:%S}".format(
			datetime.datetime.strptime(name, "%Y%m%d-%H%M%S"))
		e.executionStarts(
			timestamp= timestamp,
			changelog=[])
		e.taskStarts(1,"First task")
		if running : return
		e.taskEnds(1,ok)
		s.now = datetime.datetime(2013,4,5,6,7,8)
		e.executionEnds(ok)
示例#6
0
def emulateExecutionWithStats(self,
                              name,
                              tasks,
                              project='myproject',
                              client='myclient'):
    s = Logger("fixture")
    s = ArgPrepender(s, project, client, name)
    timestamp = "{0:%Y-%m-%d %H:%M:%S}".format(
        datetime.datetime.strptime(name, "%Y%m%d-%H%M%S"))
    s.executionStarts(timestamp=timestamp, changelog=[])
    for i, (task, commands) in enumerate(tasks):
        s.taskStarts(i + 1, task)
        for j, (line, ok, output, info, stats) in enumerate(commands):
            s.commandStarts(i + 1, j + 1, line)
            if ok is None: break  # interrupted
            s.commandEnds(i + 1,
                          j + 1,
                          output=output,
                          ok=ok,
                          info=info,
                          stats=stats)
            if ok is False: break  # Failed, fatal for the task
        if ok is None: break  # interrupted, fatal for the execution
        s.taskEnds(i + 1, ok)
    s.executionEnds(ok)
示例#7
0
 def setUpExecution(self, logpath, project, client, execution):
     s = Logger(logpath)
     s.createServer()
     s.createProject(project)
     s.createClient(project, client)
     e = ArgPrepender(s, project, client, execution)
     s.now = datetime.datetime(2013, 03, 01, 13, 23, 14)
     return e
示例#8
0
 def emulateExecution(self,
                      name,
                      ok=True,
                      running=False,
                      project='myproject',
                      client='myclient',
                      **keyw):
     s = Logger("fixture")
     s = ArgPrepender(s, project, client, name)
     timestamp = "{0:%Y-%m-%d %H:%M:%S}".format(
         datetime.datetime.strptime(name, "%Y%m%d-%H%M%S"))
     s.executionStarts(timestamp=timestamp, changelog=[])
     s.taskStarts(1, "First task")
     if running: return
     s.taskEnds(1, ok)
     s.executionEnds(ok)
示例#9
0
	def emptyExecution(self) :
		project, client, execution = "myproject", "myclient", "20130301-232425"
		s = Logger("fixture")
		s.createServer()
		s.createProject(project)
		s.createClient(project, client)
		# force an idle time
		s.now=datetime.datetime(2013,4,5,6,7,8)
		s.clientIdle("myproject", "myclient", 0)

		e = ArgPrepender(s, project, client, execution)
		e.executionStarts(
			timestamp="2013-03-01 23:24:25",
			changelog=[])
		e.executionEnds(True)
		return e.execution()
示例#10
0
	def commandFixture(self, line,
			running = False,
			ok = None,
			output=None,
			info=None,
			stats = {}
			) :
		project, client, execution = "myproject", "myclient", "20130301-232425"
		s = Logger("fixture")
		s.createServer()
		s.createProject(project)
		s.createClient(project, client)
		e = ArgPrepender(s, project, client, execution)
		e.executionStarts(
			timestamp="2013-03-01 23:24:25",
			changelog=[])
		e.taskStarts(1, "First task")
		e.commandStarts(1,1, line)
		if running : return e.execution().tasks[0].commands[0]
		e.commandEnds(1,1, output=output, ok=ok, info=info, stats=stats)
		e.taskEnds(1,True)
		e.executionEnds(True)
		return e.execution().tasks[0].commands[0]
示例#11
0
	def setUpExecution(self, logger, name, running=False, ok=True) :
		e = ArgPrepender(logger, "myproject", "myclient", name)
		timestamp = "{0:%Y-%m-%d %H:%M:%S}".format(
			datetime.datetime.strptime(name, "%Y%m%d-%H%M%S"))
		e.executionStarts(
			timestamp= timestamp,
			changelog=[])
		e.taskStarts(1, "First task")
		e.commandStarts(1,1, "command line")
		e.commandEnds(1,1, output="output", ok=ok, info=None, stats={})
		if running : return
		e.taskEnds(1,ok)
		e.executionEnds(ok)
示例#12
0
	def executionFixture(self, running = False) :
		project, client, execution = "myproject", "myclient", "20130301-232425"
		s = Logger("fixture")
		s.createServer()
		s.createProject(project)
		s.createClient(project, client)
		# force an idle time
		s.now=datetime.datetime(2013,4,5,6,7,8)
		s.clientIdle(project,client, 0)

		e = ArgPrepender(s, project, client, execution)
		e.executionStarts(
			timestamp="2013-03-01 23:24:25",
			changelog=[])
		e.taskStarts(1, "First task")
		e.commandStarts(1,1, "command line")
		if running : return e.execution()
		e.commandEnds(1,1, output="output", ok=True, info=None, stats={})
		e.taskEnds(1,True)
		e.executionEnds(True)
		return e.execution()
示例#13
0
	def taskFixture(self, description,
			commands = 0,
			id = 1,
			running = False,
			ok = None,
			info=None,
			stats = {}
			) :
		project, client, execution = "myproject", "myclient", "20130301-232425"
		s = Logger("fixture")
		e = ArgPrepender(s, project, client, execution)
		e.executionStarts(
			timestamp="2013-03-01 23:24:25",
			changelog=[])
		e.taskStarts(id, description)
		for i in xrange(commands) :
			output="output for command {}".format(i)
			ok = True
			e.commandStarts(id,i+1, "command line")
			if running : return e.execution().tasks[0]
			e.commandEnds(id,i+1, output=output, ok=ok, info=info, stats=stats)
		e.taskEnds(id,True)
		e.executionEnds(True)
		return e.execution().tasks[id-1]