Example #1
0
 def mock_remove_logically_side_effect(index, file_type):
     file_types_at_index = add_set.files.get(index, None)
     if file_types_at_index is None:
         raise FileSet.IndexUnassignedError(self, index, "The index '{}' is not assigned in the file set '{}'.".format(index, str(add_set)))
     elif len(file_types_at_index) == 1:
         add_set.files.pop(index) # remove entire index
         if index == add_set.max_index:
             add_set.max_index = add_set._find_max_index()
     else:
         file_types_at_index.remove(file_type) # only remove this type from index file_type list, since there are more types assigned
Example #2
0
 def _mock_add_files_side_effect_remove_files(file_set, _2, index_iterable, **kwargs):
     """Mock the logical behavior of add_files on the given file_set argument."""
     preserve_gaps = kwargs.get('preserve_gaps', False)
     strip_gaps = kwargs.get('strip_gaps', False)
     
     if preserve_gaps and strip_gaps:
         raise FileSet.ConflictingOptionsError()
     elif preserve_gaps or strip_gaps:
         for index in index_iterable:
             file_set.files.pop(index, None)
     else:
         for index in index_iterable:
             removal_result = file_set.files.pop(index, None)
             if removal_result is None:
                 raise FileSet.IndexUnassignedError(index, "The index {} is unassigned and thus can't be added to the set.".format(index))
Example #3
0
    def test_gap_without_gap_handler(self):
        """The CLI should raise an according CLIRuntimeError if the removal range contains a gap but no gap handling strategy has been specified."""
        test_args = ["-", "8-11"]

        mock_expand_range.return_value = (8, 11)

        mock_remove_files.side_effect = FileSet.IndexUnassignedError(
            10, "Index 10 is unassigned and thus can't be removed.")

        with self.assertRaises(
                CLIRuntimeError,
                msg=
                "The CLI fails to raise a CLIRuntimeError when encountering gaps without a gap handling strategy."
        ):
            remove(self.test_set, test_args)

        mock_assert_msg(
            mock_remove_files.assert_called_once_with,
            [[8, 9, 10, 11], self.default_remove_set],
            "The CLI doesn't correctly call the FileSet removal method.")
Example #4
0
 def mock_change_index_side_effect(f, t):
     raise FileSet.IndexUnassignedError(f, t, "Index does not exist.")
Example #5
0
 def mock_change_index_side_effect(f, t):
     raise FileSet.IndexUnassignedError(f, "Index unassigned.")
Example #6
0
 def mock_change_index_side_effect(f, _):
     if f in [0, 1, 5, 6]:
         raise FileSet.IndexUnassignedError()