Beispiel #1
0
    def test_copy_does_not_transform_if_extension_is_identical(self):
        transformer = TransformerMock()
        path_delegate = ft.TransformationAwarePathDelegate([transformer])
        path_delegate._original_copy = mock.MagicMock()
        path_delegate.remove = mock.MagicMock()

        path_delegate.copy(self.FILENAME1, self.FILENAME1)

        path_delegate._original_copy.assert_has_calls(
            [mock.call(self.FILENAME1, self.FILENAME1)])
        path_delegate.remove.assert_not_called()
        self.assertEqual(0, transformer.transformed_called)
Beispiel #2
0
    def test_copy_does_transform_if_extension_is_different(self):
        transformer = TransformerMock()
        path_delegate = ft.TransformationAwarePathDelegate([transformer])
        path_delegate._original_copy = mock.MagicMock()
        path_delegate.remove = mock.MagicMock()

        path_delegate.copy(self.FILENAME1, self.FILENAME2)

        transformed = "{}.transformed{}".format(self.FILENAME1, EXT2)
        path_delegate._original_copy.assert_has_calls(
            [mock.call(transformed, self.FILENAME2)])
        path_delegate.remove.assert_called_with(transformed)
        self.assertEqual(1, transformer.transformed_called)