OLD | NEW |
1 # This file is part of the Juju GUI, which lets users view and manage Juju | 1 # This file is part of the Juju GUI, which lets users view and manage Juju |
2 # environments within a graphical interface (https://launchpad.net/juju-gui). | 2 # environments within a graphical interface (https://launchpad.net/juju-gui). |
3 # Copyright (C) 2013 Canonical Ltd. | 3 # Copyright (C) 2013 Canonical Ltd. |
4 # | 4 # |
5 # This program is free software: you can redistribute it and/or modify it under | 5 # This program is free software: you can redistribute it and/or modify it under |
6 # the terms of the GNU Affero General Public License version 3, as published by | 6 # the terms of the GNU Affero General Public License version 3, as published by |
7 # the Free Software Foundation. | 7 # the Free Software Foundation. |
8 # | 8 # |
9 # This program is distributed in the hope that it will be useful, but WITHOUT | 9 # This program is distributed in the hope that it will be useful, but WITHOUT |
10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | 10 # ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
11 # SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 # SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 # Affero General Public License for more details. | 12 # Affero General Public License for more details. |
13 # | 13 # |
14 # You should have received a copy of the GNU Affero General Public License | 14 # You should have received a copy of the GNU Affero General Public License |
15 # along with this program. If not, see <http://www.gnu.org/licenses/>. | 15 # along with this program. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 |
17 """Tests for the bundle deployment base objects.""" | 17 """Tests for the bundle deployment base objects.""" |
18 | 18 |
19 from deployer import cli as deployer_cli | 19 from deployer import cli as deployer_cli |
20 import jujuclient | 20 import jujuclient |
21 import mock | 21 import mock |
22 from tornado import gen | 22 from tornado import gen |
23 from tornado.testing import( | 23 from tornado.testing import( |
24 AsyncTestCase, | 24 AsyncTestCase, |
25 gen_test, | 25 gen_test, |
| 26 LogTrapTestCase, |
26 ) | 27 ) |
27 | 28 |
28 from guiserver import auth | 29 from guiserver import auth |
29 from guiserver.bundles import ( | 30 from guiserver.bundles import ( |
30 base, | 31 base, |
31 utils, | 32 utils, |
32 ) | 33 ) |
33 from guiserver.tests import helpers | 34 from guiserver.tests import helpers |
34 | 35 |
35 | 36 |
(...skipping 12 matching lines...) Expand all Loading... |
48 self._exception = exception | 49 self._exception = exception |
49 | 50 |
50 def cancelled(self): | 51 def cancelled(self): |
51 return self._cancelled | 52 return self._cancelled |
52 | 53 |
53 def exception(self): | 54 def exception(self): |
54 return self._exception | 55 return self._exception |
55 | 56 |
56 | 57 |
57 @mock.patch('time.time', mock.Mock(return_value=42)) | 58 @mock.patch('time.time', mock.Mock(return_value=42)) |
58 class TestDeployer(helpers.BundlesTestMixin, AsyncTestCase): | 59 class TestDeployer(helpers.BundlesTestMixin, LogTrapTestCase, AsyncTestCase): |
59 | 60 |
60 bundle = {'foo': 'bar'} | 61 bundle = {'foo': 'bar'} |
61 user = auth.User( | 62 user = auth.User( |
62 username='myuser', password='mypasswd', is_authenticated=True) | 63 username='myuser', password='mypasswd', is_authenticated=True) |
63 | 64 |
64 def assert_change( | 65 def assert_change( |
65 self, changes, deployment_id, status, queue=None, error=None): | 66 self, changes, deployment_id, status, queue=None, error=None): |
66 """Ensure only one change is present in the given changes. | 67 """Ensure only one change is present in the given changes. |
67 | 68 |
68 Also check the change refers to the expected deployment id and status. | 69 Also check the change refers to the expected deployment id and status. |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 return {'Response': 'ok'} | 487 return {'Response': 'ok'} |
487 | 488 |
488 # Patch the routes so that the customized view defined above is called | 489 # Patch the routes so that the customized view defined above is called |
489 # when an import request is processed. | 490 # when an import request is processed. |
490 self.deployment.routes['Import'] = view | 491 self.deployment.routes['Import'] = view |
491 yield self.deployment.process_request(deployment_request) | 492 yield self.deployment.process_request(deployment_request) |
492 # Ensure the response has been correctly sent. | 493 # Ensure the response has been correctly sent. |
493 self.assertEqual(1, len(self.responses)) | 494 self.assertEqual(1, len(self.responses)) |
494 response = self.responses[0] | 495 response = self.responses[0] |
495 self.assertEqual({'RequestId': 42, 'Response': 'ok'}, response) | 496 self.assertEqual({'RequestId': 42, 'Response': 'ok'}, response) |
OLD | NEW |