def test_was_modified_since_specific(self): """VirtualDownloadView.was_modified_since() delegates to file wrapper.""" file_wrapper = mock.Mock() file_wrapper.was_modified_since = mock.Mock( return_value=mock.sentinel.from_file_wrapper) view = views.VirtualDownloadView() since = mock.sentinel.since return_value = view.was_modified_since(file_wrapper, since) self.assertTrue(return_value is mock.sentinel.from_file_wrapper) file_wrapper.was_modified_since.assert_called_once_with(since)
def test_was_modified_since_not_implemented(self): """VirtualDownloadView.was_modified_since() returns True if file wrapper does not implement ``was_modified_since()``.""" file_wrapper = mock.Mock() file_wrapper.was_modified_since = mock.Mock(side_effect=AttributeError) modified_time = mock.PropertyMock() setattr(file_wrapper, 'modified_time', modified_time) size = mock.PropertyMock() setattr(file_wrapper, 'size', size) view = views.VirtualDownloadView() since = mock.sentinel.since result = view.was_modified_since(file_wrapper, since) self.assertTrue(result is True) self.assertFalse(modified_time.called) self.assertFalse(size.called)