-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added configurable scp put timeout. added tests #121
Open
TAlonglong
wants to merge
5
commits into
pytroll:main
Choose a base branch
from
TAlonglong:issue120-scpclient-timeout-config
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9017bef
added configurable scp put timeout. added tests
1639d84
Merge branch 'main' into issue120-scpclient-timeout-config
TAlonglong ef0b681
fix stikler
a720abb
Merge branch 'issue120-scpclient-timeout-config' of github.com:TAlong…
570883d
need to be a value
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
# | ||
# Copyright (c) 2019 | ||
# Copyright (c) 2019, 2022 | ||
# | ||
# Author(s): | ||
# | ||
|
@@ -54,6 +54,7 @@ def setUp(self): | |
|
||
self._attrs_empty = {} | ||
self._attrs_connection_uptime = {'connection_uptime': 0} | ||
self._attrs_timeout = {'scpclient_timeout_seconds': 1} | ||
|
||
def tearDown(self): | ||
try: | ||
|
@@ -178,6 +179,18 @@ def test_scp_copy(self, mock_scp_client, mock_sshclient): | |
|
||
mocked_scp_client.put.assert_called_once_with(self.origin, urlparse(self.destination_no_port).path) | ||
|
||
@patch('trollmoves.movers.SSHClient', autospec=True) | ||
@patch('trollmoves.movers.SCPClient', autospec=True) | ||
def test_scp_copy_custom_timeout(self, mock_scp_client, mock_sshclient): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The timeout isn't tested in this test, so either adjust the name or test the timeout. |
||
"""Check scp copy.""" | ||
mocked_scp_client = MagicMock() | ||
mock_scp_client.return_value = mocked_scp_client | ||
|
||
scp_mover = trollmoves.movers.ScpMover(self.origin, self.destination_no_port, attrs=self._attrs_timeout) | ||
scp_mover.copy() | ||
|
||
mocked_scp_client.put.assert_called_once_with(self.origin, urlparse(self.destination_no_port).path) | ||
|
||
@patch('trollmoves.movers.SSHClient', autospec=True) | ||
@patch('trollmoves.movers.SCPClient', autospec=True) | ||
def test_scp_copy_generic_exception(self, mock_scp_client, mock_sshclient): | ||
|
@@ -216,6 +229,26 @@ def test_scp_copy_put_exception(self, mock_scp_client): | |
with pytest.raises(Exception): | ||
scp_mover.copy() | ||
|
||
@patch('trollmoves.movers.SCPClient', autospec=True) | ||
def test_scp_copy_put_SCPException(self, mock_scp_client): | ||
"""Check scp client.put() raising SCPException.""" | ||
from scp import SCPException | ||
scp_mover = trollmoves.movers.ScpMover(self.origin, self.destination_no_port, attrs=self._attrs_empty) | ||
mock_scp_client.return_value.put.side_effect = SCPException('Timeout waiting for scp response') | ||
|
||
with pytest.raises(SCPException, match='Timeout waiting for scp response'): | ||
scp_mover.copy() | ||
|
||
@patch('trollmoves.movers.SCPClient', autospec=True) | ||
def test_scp_copy_put_SCPException2(self, mock_scp_client): | ||
"""Check scp client.put() raising SCPException.""" | ||
from scp import SCPException | ||
scp_mover = trollmoves.movers.ScpMover(self.origin, self.destination_no_port, attrs=self._attrs_empty) | ||
mock_scp_client.return_value.put.side_effect = SCPException('Other exception') | ||
|
||
with pytest.raises(SCPException, match='Other exception'): | ||
scp_mover.copy() | ||
|
||
@patch('trollmoves.movers.SSHClient', autospec=True) | ||
@patch('trollmoves.movers.SCPClient', autospec=True) | ||
def test_scp_move(self, mock_scp_client, mock_sshclient): | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see this in
main
at all, so don't know where it's coming from. Should be safe to remove.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, actually, it's coming from this PR since it shows up in the diff.