def test_BugTaskCommandGroup_add(self): # BugEmailCommands can be added to the group. command_1 = BugEmailCommands.get('affects', ['fnord']) command_2 = BugEmailCommands.get('status', ['triaged']) group = BugTaskCommandGroup() group.add(command_1) group.add(command_2) self.assertEqual([command_1, command_2], group._commands)
def test_BugTaskCommandGroup__str__(self): # The str of a BugTaskCommandGroup is the ideal order of the # text commands in the email. command_1 = BugEmailCommands.get('affects', ['fnord']) command_2 = BugEmailCommands.get('status', ['triaged']) group = BugTaskCommandGroup() group.add(command_1) group.add(command_2) self.assertEqual('affects fnord\nstatus triaged', str(group))
def test_BugTaskCommandGroup__str__(self): # The str of a BugTaskCommandGroup is the ideal order of the # text commands in the email. command_1 = BugEmailCommands.get('affects', ['fnord']) command_2 = BugEmailCommands.get('status', ['triaged']) group = BugTaskCommandGroup() group.add(command_1) group.add(command_2) self.assertEqual( 'affects fnord\nstatus triaged', str(group))
def test_BugCommandGroup_groups(self): # The groups property returns a copy _groups list in the order that # that they were added. bugtask_group_1 = BugTaskCommandGroup( BugEmailCommands.get('affects', ['fnord'])) group = BugCommandGroup() group.add(bugtask_group_1) bugtask_group_2 = BugTaskCommandGroup( BugEmailCommands.get('affects', ['pting'])) group.add(bugtask_group_2) self.assertEqual(group._groups, group.groups) self.assertFalse(group._groups is group.groups) self.assertEqual([bugtask_group_1, bugtask_group_2], group.groups)
def test_BugTaskCommandGroup_sorted_commands(self): # Commands are sorted by the Command's Rank. command_3 = BugEmailCommands.get('importance', ['low']) command_2 = BugEmailCommands.get('status', ['triaged']) command_1 = BugEmailCommands.get('affects', ['fnord']) group = BugTaskCommandGroup() group.add(command_3) group.add(command_2) group.add(command_1) self.assertEqual(0, command_1.RANK) self.assertEqual(4, command_2.RANK) self.assertEqual(5, command_3.RANK) self.assertEqual( [command_1, command_2, command_3], group.commands)
def test_BugCommandGroup_groups_new_bug_with_fixable_affects(self): # A new bug that affects only one target does not require the # affects command to be first. group = BugCommandGroup(BugEmailCommands.get('bug', ['new'])) status_command = BugEmailCommands.get('status', ['triaged']) bugtask_group_1 = BugTaskCommandGroup(status_command) group.add(bugtask_group_1) affects_command = BugEmailCommands.get('affects', ['fnord']) bugtask_group_2 = BugTaskCommandGroup(affects_command) group.add(bugtask_group_2) self.assertEqual(1, len(group.groups)) self.assertIsNot(group._groups, group.groups, "List reference returned instead of copy.") self.assertEqual([affects_command, status_command], group.groups[0].commands)
def test_BugCommandGroup_add_bugtask_empty_group(self): # Empty BugTaskCommandGroups are ignored. bugtask_group = BugTaskCommandGroup() group = BugCommandGroup() group.add(bugtask_group) self.assertEqual([], group._commands) self.assertEqual([], group._groups)
def test_BugCommandGroup__nonzero__true_groups(self): # A BugCommandGroup is not zero is it has a group. group = BugCommandGroup() group.add( BugTaskCommandGroup(BugEmailCommands.get('affects', ['fnord']))) self.assertEqual(0, len(group._commands)) self.assertEqual(1, len(group._groups)) self.assertTrue(bool(group))
def test_BugCommandGroup_add_bugtask_non_empty_group(self): # Non-empty BugTaskCommandGroups are added. bugtask_group = BugTaskCommandGroup( BugEmailCommands.get('affects', ['fnord'])) group = BugCommandGroup() group.add(bugtask_group) self.assertEqual([], group._commands) self.assertEqual([bugtask_group], group._groups)
def test_BugCommandGroup__str__(self): # The str of a BugCommandGroup is the ideal order of the # text commands in the email. bug_group = BugCommandGroup(BugEmailCommands.get('private', ['true'])) bug_group.add(BugEmailCommands.get('security', ['false'])) bugtask_group = BugTaskCommandGroup( BugEmailCommands.get('affects', ['fnord'])) bug_group.add(bugtask_group) self.assertEqual('security false\nprivate true\naffects fnord', str(bug_group))
def test_BugTaskCommandGroup_sorted_commands(self): # Commands are sorted by the Command's Rank. command_3 = BugEmailCommands.get('importance', ['low']) command_2 = BugEmailCommands.get('status', ['triaged']) command_1 = BugEmailCommands.get('affects', ['fnord']) group = BugTaskCommandGroup() group.add(command_3) group.add(command_2) group.add(command_1) self.assertEqual(0, command_1.RANK) self.assertEqual(4, command_2.RANK) self.assertEqual(5, command_3.RANK) self.assertEqual([command_1, command_2, command_3], group.commands)
def test_BugTaskCommandGroup__nonzero__false(self): # A BugTaskCommandGroup is zero is it has no commands. group = BugTaskCommandGroup() self.assertEqual(0, len(group._commands)) self.assertFalse(bool(group))
def test_BugTaskCommandGroup_init_with_command(self): # BugTaskCommandGroup can be inited with a BugEmailCommands. command = BugEmailCommands.get('status', ['triaged']) group = BugTaskCommandGroup(command) self.assertEqual([command], group._commands)