class RemovePuppetModulesCommand(base_cli.ExtensionTests):

    def setUp(self):
        super(RemovePuppetModulesCommand, self).setUp()
        self.command = RemoveCommand(self.context)

    def test_defaults(self):
        self.assertTrue(isinstance(self.command, UnitRemoveCommand))
        self.assertEqual('remove', self.command.name)
        self.assertEqual(DESC_REMOVE, self.command.description)
        self.assertEqual(DISPLAY_MODULES_THRESHOLD, self.command.module_count_threshold)
        # uses default remove method
        self.assertEqual(self.command.method, self.command.run)

    @mock.patch('pulp_puppet.extensions.admin.repo.units_display.display_modules')
    def test_succeeded(self, mock_display):
        # Setup
        fake_modules = 'm'
        fake_task = mock.MagicMock()
        fake_task.result = fake_modules

        # Test
        self.command.succeeded(fake_task)

        # Verify
        mock_display.assert_called_once_with(self.prompt, fake_modules, self.command.module_count_threshold)
class RemovePuppetModulesCommand(base_cli.ExtensionTests):
    def setUp(self):
        super(RemovePuppetModulesCommand, self).setUp()
        self.command = RemoveCommand(self.context)

    def test_defaults(self):
        self.assertTrue(isinstance(self.command, UnitRemoveCommand))
        self.assertEqual('remove', self.command.name)
        self.assertEqual(DESC_REMOVE, self.command.description)
        self.assertEqual(DISPLAY_MODULES_THRESHOLD,
                         self.command.module_count_threshold)
        # uses default remove method
        self.assertEqual(self.command.method, self.command.run)

    @mock.patch(
        'pulp_puppet.extensions.admin.repo.units_display.display_modules')
    def test_succeeded(self, mock_display):
        # Setup
        fake_modules = 'm'
        fake_task = mock.MagicMock()
        fake_task.result = fake_modules

        # Test
        self.command.succeeded(fake_task)

        # Verify
        mock_display.assert_called_once_with(
            self.prompt, fake_modules, self.command.module_count_threshold)
Example #3
0
    def test_get_formatter_for_type(self, mock_formatter):
        context = mock.MagicMock()
        command = RemoveCommand(context)

        command.get_formatter_for_type(TYPE_PUPPET_MODULE)
        mock_formatter.assert_called_once_with(TYPE_PUPPET_MODULE)
Example #4
0
 def setUp(self):
     super(RemovePuppetModulesCommand, self).setUp()
     self.command = RemoveCommand(self.context)
 def setUp(self):
     super(RemovePuppetModulesCommand, self).setUp()
     self.command = RemoveCommand(self.context)
Example #6
0
    def test_get_formatter_for_type(self, mock_formatter):
        context = mock.MagicMock()
        command = RemoveCommand(context)

        command.get_formatter_for_type(TYPE_PUPPET_MODULE)
        mock_formatter.assert_called_once_with(TYPE_PUPPET_MODULE)