Пример #1
0
class TestTaskRunner(unittest.TestCase):

	def setUp(self):
		self.runner = TaskRunner()

	def do_nothing(self):
		pass

	def test_build_task_list(self):
		raw_tasks = [{"name": "A","instructions": "1"},{"name": "C","instructions": "3","depends": "B"},{"name": "B","instructions": "2","depends": "A"}]
	
		self.runner.start_tasks = MagicMock(return_value=None)
		self.runner.build_task_list(raw_tasks)

		self.assertEqual(len(self.runner.loaded_tasks), 3)
		self.assertEqual(len(self.runner.task_list), 3)

	def test_fail_build_task_list(self):
		raw_tasks = [{"name": "A","instructions": "1", "depends":"B"}]
		self.runner.start_tasks = MagicMock(return_value=None)
		self.runner.build_task_list(raw_tasks)

		self.assertEqual(len(self.runner.loaded_tasks), 1)
		self.assertEqual(len(self.runner.task_list), 1)


	def test_task_by_name(self):
		raw_task = {"name": "A","instructions": "1", "depends":"B"}
		task = Task(raw_task)
		self.runner.loaded_tasks = [task]

		self.assertEqual(len(self.runner.loaded_tasks), 1)
		self.assertEqual(self.runner.find_task_by_name('A'), task)
Пример #2
0
	def setUp(self):
		self.runner = TaskRunner()
Пример #3
0
import unittest
import sys

def banner():
	''' Display the information banner '''
	print 'Welcome to Taskatron, known commands are as follows:'
	print 'test -- runs all of the unit tests'
	print 'load FILE_NAME -- runs the tasks in the provided file'

args = sys.argv
if len(args) >= 2: 
	command = args[1]

	if command.lower() == 'load':
		if len(args) >=3:
			filename =  args[2]

			if filename:
				task_runner = TaskRunner()
				task_runner.load_tasks_from_file(filename)
		else:
			print 'No filename specified for [load] command'
	else:
		# Start the unit tests
		suite = unittest.TestLoader().loadTestsFromTestCase(TestBaseLine)
		unittest.TextTestRunner(verbosity=2).run(suite)

		suite = unittest.TestLoader().loadTestsFromTestCase(TestTaskRunner)
		unittest.TextTestRunner(verbosity=2).run(suite)
else:
	banner()