~tomasgroth/openlp/portable-path

« back to all changes in this revision

Viewing changes to tests/functional/openlp_core/common/test_httputils.py

  • Committer: Tomas Groth
  • Date: 2019-04-30 19:02:42 UTC
  • mfrom: (2829.2.32 openlp)
  • Revision ID: tomasgroth@yahoo.dk-20190430190242-6zwjk8724tyux70m
trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
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)
225
225
 
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
229
229
 
230
230
    @patch('openlp.core.common.httputils.requests')
249
249
        self.addCleanup(self.destroy_settings)
250
250
 
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):
253
253
        """
254
254
        Test that the argument is used rather than reading the 'advanced/proxy mode' setting
255
255
        """
256
256
        # GIVEN: Mocked settings
257
 
        mocked_settings = MagicMock()
258
 
        MockSettings.return_value = mocked_settings
259
257
 
260
258
        # WHEN: Calling `get_proxy_settings` with the mode arg specified
261
259
        get_proxy_settings(mode=ProxyMode.NO_PROXY)
262
260
 
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()
265
263
 
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):
268
266
        """
269
267
        Test that the system settings are used when the mode arg specieied is invalid
270
268
        """
271
269
        # GIVEN: Mocked settings
272
 
        mocked_settings = MagicMock()
273
 
        MockSettings.return_value = mocked_settings
274
270
 
275
271
        # WHEN: Calling `get_proxy_settings` with an invalid mode arg specified
276
272
        result = get_proxy_settings(mode='qwerty')
277
273
 
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
281
277
 
282
278
    def test_no_proxy_mode(self):