def test_summarize_keeps_nonstandard_status(self): fake_tasks_table = [{'job-name': 'job1', 'status': 'FLYING'}] expected_table = [ collections.OrderedDict([('job-name', 'job1'), ('status', 'FLYING'), ('task-count', 1)]) ] table = dstat_command._prepare_summary_table(fake_tasks_table) self.assertEqual(table, expected_table)
def test_summarize_removes_extra_fields(self): fake_tasks_table = [{ 'job-name': 'job1', 'status': 'RUNNING', 'favorite color': 'pink' }] expected_table = [ collections.OrderedDict([('job-name', 'job1'), ('status', 'RUNNING'), ('task-count', 1)]) ] table = dstat_command._prepare_summary_table(fake_tasks_table) self.assertEqual(table, expected_table)
def test_summarize_can_count(self): fake_tasks_table = [{ 'job-name': 'job1', 'status': 'RUNNING' }, { 'job-name': 'job1', 'status': 'RUNNING' }] expected_table = [ collections.OrderedDict([('job-name', 'job1'), ('status', 'RUNNING'), ('task-count', 2)]) ] table = dstat_command._prepare_summary_table(fake_tasks_table) self.assertEqual(table, expected_table)
def test_summarize_puts_running_before_failure(self): fake_tasks_table = [{ 'job-name': 'job1', 'status': 'FAILURE' }, { 'job-name': 'job1', 'status': 'RUNNING' }] expected_table = [ collections.OrderedDict([('job-name', 'job1'), ('status', 'RUNNING'), ('task-count', 1)]), collections.OrderedDict([('job-name', 'job1'), ('status', 'FAILURE'), ('task-count', 1)]) ] table = dstat_command._prepare_summary_table(fake_tasks_table) self.assertEqual(table, expected_table)