4
4
###############################################################################
5
5
# OpenLP - Open Source Lyrics Projection #
6
6
# --------------------------------------------------------------------------- #
7
# Copyright (c) 2008-2018 OpenLP Developers #
7
# Copyright (c) 2008-2019 OpenLP Developers #
8
8
# --------------------------------------------------------------------------- #
9
9
# This program is free software; you can redistribute it and/or modify it #
10
10
# under the terms of the GNU General Public License as published by the Free #
224
224
file_size = get_url_file_size(fake_url)
226
226
# THEN: The correct methods are called with the correct arguments and a web page is returned
227
mocked_requests.head.assert_called_once_with(fake_url, allow_redirects=True, timeout=30.0)
227
mocked_requests.head.assert_called_once_with(fake_url, allow_redirects=True, proxies=None, timeout=30.0)
228
228
assert file_size == 100
230
230
@patch('openlp.core.common.httputils.requests')
249
249
self.addCleanup(self.destroy_settings)
251
251
@patch('openlp.core.common.httputils.Settings')
252
def test_mode_arg_specified(self, MockSettings):
252
def test_mode_arg_specified(self, mocked_settings):
254
254
Test that the argument is used rather than reading the 'advanced/proxy mode' setting
256
256
# GIVEN: Mocked settings
257
mocked_settings = MagicMock()
258
MockSettings.return_value = mocked_settings
260
258
# WHEN: Calling `get_proxy_settings` with the mode arg specified
261
259
get_proxy_settings(mode=ProxyMode.NO_PROXY)
263
261
# THEN: The mode arg should have been used rather than looking it up in the settings
264
mocked_settings.value.assert_not_called()
262
mocked_settings().value.assert_not_called()
266
264
@patch('openlp.core.common.httputils.Settings')
267
def test_mode_incorrect_arg_specified(self, MockSettings):
265
def test_mode_incorrect_arg_specified(self, mocked_settings):
269
267
Test that the system settings are used when the mode arg specieied is invalid
271
269
# GIVEN: Mocked settings
272
mocked_settings = MagicMock()
273
MockSettings.return_value = mocked_settings
275
271
# WHEN: Calling `get_proxy_settings` with an invalid mode arg specified
276
272
result = get_proxy_settings(mode='qwerty')
278
274
# THEN: An None should be returned
279
mocked_settings.value.assert_not_called()
275
mocked_settings().value.assert_not_called()
280
276
assert result is None
282
278
def test_no_proxy_mode(self):