def test_copy_existing_abort( self, mocked_exists, mocked_makedirs_p, mocked_contents, mocked_path, mocked_copy, mocked_input, ): """Test to copy files in an existing directory and abort """ mocked_exists.return_value = True mocked_contents.return_value = [ "file1.ext", "file2.ext", "__init__.py" ] mocked_path.return_value.__enter__.side_effect = [ "path/to/file1.ext", "path/to/file2.ext", ] mocked_input.return_value = "no" user_resource_files.copy_resource("package.resources", Path("destination"), False) mocked_exists.assert_called_with(Path("destination")) mocked_makedirs_p.assert_not_called() mocked_contents.assert_not_called() mocked_copy.assert_not_called()
def test_copy( self, mocked_exists, mocked_makedirs_p, mocked_contents, mocked_path, mocked_copy, ): """Test to copy files in a non existing directory """ mocked_exists.return_value = False mocked_contents.return_value = [ "file1.ext", "file2.ext", "__init__.py" ] mocked_path.return_value.__enter__.side_effect = [ "path/to/file1.ext", "path/to/file2.ext", ] user_resource_files.copy_resource("package.resources", Path("destination"), False) mocked_exists.assert_called_with(Path("destination")) mocked_makedirs_p.assert_called_with(Path("destination")) mocked_contents.assert_called_with("package.resources") mocked_copy.assert_has_calls([ call(Path("path/to/file1.ext"), "destination"), call(Path("path/to/file2.ext"), "destination"), ])