Example #1
0
    def test_remove_missing_canceled(self):
        """
        Test that when the sync is canceled, no units are removed.
        """
        mock_unit = Mock()
        mock_conduit = Mock()
        method = SynchronizeWithDirectory(mock_conduit, {})
        method.canceled = True

        method._remove_missing([mock_unit], [])
        self.assertEqual(0, mock_conduit.remove_unit.call_count)
Example #2
0
    def test_remove_missing_canceled(self):
        """
        Test that when the sync is canceled, no units are removed.
        """
        mock_unit = Mock()
        mock_conduit = Mock()
        method = SynchronizeWithDirectory(mock_conduit, {})
        method.canceled = True

        method._remove_missing([mock_unit], [])
        self.assertEqual(0, mock_conduit.remove_unit.call_count)
Example #3
0
    def test_import_modules_cancelled(self, mock_extract):
        config = {}
        mock_conduit = Mock()
        mock_conduit.get_units.return_value = []

        # test
        method = SynchronizeWithDirectory(mock_conduit, config)
        method.canceled = True
        method._import_modules(['/path1', '/path2'])

        # validation
        self.assertFalse(mock_extract.called)
Example #4
0
    def test_import_modules_cancelled(self, mock_extract):
        config = {}
        mock_conduit = Mock()
        mock_conduit.get_units.return_value = []

        # test
        method = SynchronizeWithDirectory(mock_conduit, config)
        method.canceled = True
        method._import_modules(['/path1', '/path2'])

        # validation
        self.assertFalse(mock_extract.called)
Example #5
0
    def test_import_modules_cancelled(self, mock_extract):
        config = {}
        mock_conduit = Mock()
        mock_inventory = Mock()

        # test

        method = SynchronizeWithDirectory(mock_conduit, config)
        method.canceled = True
        imported_modules = method._import_modules(mock_inventory, ['/path1', '/path2'])

        # validation

        self.assertFalse(mock_extract.called)
        self.assertEqual(imported_modules, [])
Example #6
0
    def test_purge_unwanted_modules_canceled(self):
        mock_conduit = Mock()

        config = Mock()
        config.get_boolean = Mock(side_effect={constants.CONFIG_REMOVE_MISSING: True}.get)

        mock_inventory = Mock()
        mock_inventory.unwanted_modules = Mock(return_value=['A', 'B'])

        # test

        method = SynchronizeWithDirectory(mock_conduit, config)
        method.canceled = True
        method._purge_unwanted_modules(mock_inventory, [])

        # validation

        self.assertFalse(mock_conduit.remove_unit.called)
        self.assertFalse(mock_conduit.remove_unit.called)