~alisonken1/openlp/strings-core-ui

« back to all changes in this revision

Viewing changes to tests/functional/openlp_plugins/remotes/test_router.py

  • Committer: Tim Bentley
  • Date: 2016-05-19 06:00:35 UTC
  • mfrom: (2661.1.5 mayfixes)
  • Revision ID: tim.bentley@gmail.com-20160519060035-l8coui336at0fode
Fix ssl version to allow Android to use ssl. SSL is now auto negotiated. Fix SeriveManager service theme hiding. Bug since 1.9 series. Fix missing check dependancies for six, Fix PEP 8 errors

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
            (r'^/stage/api/poll$', {'function': mocked_function, 'secure': False}),
95
95
        ]
96
96
        self.router.routes = test_route
 
97
        self.router.command = 'GET'
97
98
 
98
99
        # WHEN: called with a poll route
99
100
        function, args = self.router.process_http_request('/stage/api/poll', None)
121
122
        self.router.send_header = MagicMock()
122
123
        self.router.end_headers = MagicMock()
123
124
        self.router.wfile = MagicMock()
 
125
        self.router.command = 'GET'
124
126
 
125
127
        # WHEN: called with a poll route
126
128
        self.router.do_post_processor()
211
213
            self.router.send_header.assert_called_once_with('Content-type', 'text/html')
212
214
            self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
213
215
 
 
216
    def serve_file_with_partial_params_test(self):
 
217
        """
 
218
        Test the serve_file method with an existing file
 
219
        """
 
220
        # GIVEN: mocked environment
 
221
        self.router.send_response = MagicMock()
 
222
        self.router.send_header = MagicMock()
 
223
        self.router.end_headers = MagicMock()
 
224
        self.router.wfile = MagicMock()
 
225
        self.router.html_dir = os.path.normpath('test/dir')
 
226
        self.router.template_vars = MagicMock()
 
227
        with patch('openlp.core.lib.os.path.exists') as mocked_exists, \
 
228
                patch('builtins.open', mock_open(read_data='123')):
 
229
            mocked_exists.return_value = True
 
230
 
 
231
            # WHEN: call serve_file with an existing html file
 
232
            self.router.serve_file(os.path.normpath('test/dir/test'))
 
233
 
 
234
            # THEN: it should return a 200 and the file
 
235
            self.router.send_response.assert_called_once_with(200)
 
236
            self.router.send_header.assert_called_once_with('Content-type', 'text/html')
 
237
            self.assertEqual(self.router.end_headers.call_count, 1, 'end_headers called once')
 
238
 
214
239
    def serve_thumbnail_without_params_test(self):
215
240
        """
216
241
        Test the serve_thumbnail routine without params