Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion airflow/providers/samba/hooks/samba.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def __exit__(self, exc_type, exc_value, traceback):
self._connection_cache.clear()

def _join_path(self, path):
return f"//{posixpath.join(self._host, self._share, path)}"
return f"//{posixpath.join(self._host, self._share, path.lstrip('/'))}"

@wraps(smbclient.link)
def link(self, src, dst, follow_symlinks=True):
Expand Down
12 changes: 12 additions & 0 deletions tests/providers/samba/hooks/test_samba.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,15 @@ def test_method(self, name, get_conn_mock):

# We expect keyword arguments to include the connection settings.
assert dict(kwargs, **connection_settings) == p_kwargs

@parameterized.expand(
[
("/start/path/with/slash", "//ip/share/start/path/with/slash"),
("start/path/without/slash", "//ip/share/start/path/without/slash"),
],
)
@mock.patch('airflow.hooks.base.BaseHook.get_connection')
def test__join_path(self, path, full_path, get_conn_mock):
get_conn_mock.return_value = CONNECTION
hook = SambaHook('samba_default')
assert hook._join_path(path) == full_path