Skip to content

Commit

Permalink
Make "timeout_in_seconds" optional
Browse files Browse the repository at this point in the history
  • Loading branch information
JohanLorenzo committed Jan 30, 2018
1 parent d81a10f commit 94b8cb1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
5 changes: 3 additions & 2 deletions examples/config.example.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

"ship_it_instances": {
"project:releng:ship-it:dev": {
"api_root": "http://ship-it.tld/",
"timeout_in_seconds": 60,
"username": "some@user.name",
"password": "50mep@ssword",
"api_root": "http://ship-it.tld/"
"password": "50mep@ssword"
}
},

Expand Down
2 changes: 1 addition & 1 deletion shipitscript/ship_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def mark_as_shipped(ship_it_instance_config, release_name):
"""
auth = (ship_it_instance_config['username'], ship_it_instance_config['password'])
api_root = ship_it_instance_config['api_root']
timeout_in_seconds = int(ship_it_instance_config['timeout_in_seconds'])
timeout_in_seconds = int(ship_it_instance_config.get('timeout_in_seconds', 60))
release_api = shipitapi.Release(auth, api_root=api_root, timeout=timeout_in_seconds)

shipped_at = datetime.utcnow().strftime('%Y-%m-%d %H:%M:%S')
Expand Down
13 changes: 10 additions & 3 deletions shipitscript/test/test_ship_actions.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import pytest
import shipitapi

from freezegun import freeze_time
Expand All @@ -7,7 +8,12 @@


@freeze_time('2018-01-19 12:59:59')
def test_mark_as_shipped(monkeypatch):
@pytest.mark.parametrize('timeout, expected_timeout', (
(1, 1),
('10', 10),
(None, 60),
))
def test_mark_as_shipped(monkeypatch, timeout, expected_timeout):
ReleaseClassMock = MagicMock()
release_instance_mock = MagicMock()
ReleaseClassMock.side_effect = lambda *args, **kwargs: release_instance_mock
Expand All @@ -17,15 +23,16 @@ def test_mark_as_shipped(monkeypatch):
'username': 'some-username',
'password': 'some-password',
'api_root': 'http://some.ship-it.tld/api/root',
'timeout_in_seconds': 1,
}
if timeout is not None:
ship_it_instance_config['timeout_in_seconds'] = timeout
release_name = 'Firefox-59.0b1-build1'
mark_as_shipped(ship_it_instance_config, release_name)

ReleaseClassMock.assert_called_with(
('some-username', 'some-password'),
api_root='http://some.ship-it.tld/api/root',
timeout=1,
timeout=expected_timeout,
)
release_instance_mock.update.assert_called_with(
'Firefox-59.0b1-build1', status='shipped', shippedAt='2018-01-19 12:59:59'
Expand Down

0 comments on commit 94b8cb1

Please sign in to comment.