Debian Codegraph @

tests/url_dispatcher_testability/test_fake_dispatcher.py.in

raw
1 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2 #
3 # Copyright (C) 2014 Canonical Ltd.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; version 3.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 import testtools
18 from url_dispatcher_testability import fixture_setup, fake_dispatcher
19
20 from subprocess import call, CalledProcessError
21
22
23 class FakeDispatcherTestCase(testtools.TestCase):
24
25 def setUp(self):
26 super(FakeDispatcherTestCase, self).setUp()
27 self.dispatcher = fixture_setup.FakeURLDispatcher()
28 self.useFixture(self.dispatcher)
29
30 def test_url_dispatcher(self):
31 bin_dir = "@PROJECT_BINARY_DIR@"
32 result = call([bin_dir + '/tools/lomiri-url-dispatcher', 'test://testurl'])
33 self.assertEqual(0, result)
34 try:
35 last_url = self.dispatcher.get_last_dispatch_url_call_parameter()
36 except fake_dispatcher.FakeDispatcherException:
37 last_url = None
38 self.assertEqual(last_url, 'test://testurl')
39
40 def test_url_dispatcher_no_args(self):
41 bin_dir = "@PROJECT_BINARY_DIR@"
42 result = call([bin_dir + '/tools/lomiri-url-dispatcher'])
43 self.assertEqual(1, result)