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) 2012-2013 Canonical Ltd. | 3 # Copyright (C) 2012-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, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 self.assertEqual([series], os.listdir(repo)) | 83 self.assertEqual([series], os.listdir(repo)) |
84 series_dir = os.path.join(repo, series) | 84 series_dir = os.path.join(repo, series) |
85 self.assert_dir_exists(series_dir) | 85 self.assert_dir_exists(series_dir) |
86 # The series directory only contains our charm. | 86 # The series directory only contains our charm. |
87 self.assertEqual([self.name], os.listdir(series_dir)) | 87 self.assertEqual([self.name], os.listdir(series_dir)) |
88 self.assert_dir_exists(os.path.join(series_dir, self.name)) | 88 self.assert_dir_exists(os.path.join(series_dir, self.name)) |
89 | 89 |
90 def test_repository(self): | 90 def test_repository(self): |
91 # The charm repository is correctly created with the default series. | 91 # The charm repository is correctly created with the default series. |
92 repo = setup_repository(self.name, self.source) | 92 repo = setup_repository(self.name, self.source) |
93 self.check_repository(repo, 'precise') | 93 self.check_repository(repo, 'trusty') |
94 | 94 |
95 def test_series(self): | 95 def test_series(self): |
96 # The charm repository is created with the given series. | 96 # The charm repository is created with the given series. |
97 repo = setup_repository(self.name, self.source, series='raring') | 97 repo = setup_repository(self.name, self.source, series='raring') |
98 self.check_repository(repo, 'raring') | 98 self.check_repository(repo, 'raring') |
99 | 99 |
100 def test_charm_files(self): | 100 def test_charm_files(self): |
101 # The charm files are correctly copied inside the repository, excluding | 101 # The charm files are correctly copied inside the repository, excluding |
102 # unwanted directories. | 102 # unwanted directories. |
103 repo = setup_repository(self.name, self.source) | 103 repo = setup_repository(self.name, self.source) |
104 charm_dir = os.path.join(repo, 'precise', self.name) | 104 charm_dir = os.path.join(repo, 'trusty', self.name) |
105 expected = set([ | 105 expected = set([ |
106 os.path.basename(self.root_file) | 106 os.path.basename(self.root_file) |
107 ]) | 107 ]) |
108 self.assert_files_equal(expected, charm_dir) | 108 self.assert_files_equal(expected, charm_dir) |
109 | 109 |
110 | 110 |
111 REPO_PATH = '/tmp/repo/' | 111 REPO_PATH = '/tmp/repo/' |
112 | 112 |
113 | 113 |
114 @mock.patch('deploy.setup_repository', mock.Mock(return_value=REPO_PATH)) | 114 @mock.patch('deploy.setup_repository', mock.Mock(return_value=REPO_PATH)) |
115 class TestJujuDeploy(unittest.TestCase): | 115 class TestJujuDeploy(unittest.TestCase): |
116 | 116 |
117 unit_info = {'public-address': 'unit.example.com'} | 117 unit_info = {'public-address': 'unit.example.com'} |
118 charm = 'test-charm' | 118 charm = 'test-charm' |
119 local_charm = 'local:precise/{}'.format(charm) | 119 local_charm = 'local:trusty/{}'.format(charm) |
120 | 120 |
121 @mock.patch('deploy.juju') | 121 @mock.patch('deploy.juju') |
122 @mock.patch('deploy.wait_for_unit') | 122 @mock.patch('deploy.wait_for_unit') |
123 def call_deploy( | 123 def call_deploy( |
124 self, mock_wait_for_unit, mock_juju, | 124 self, mock_wait_for_unit, mock_juju, |
125 service_name=None, options=None, force_machine=None, | 125 service_name=None, options=None, force_machine=None, |
126 charm_source=None, series='precise'): | 126 charm_source=None, series='trusty'): |
127 mock_wait_for_unit.return_value = self.unit_info | 127 mock_wait_for_unit.return_value = self.unit_info |
128 if charm_source is None: | 128 if charm_source is None: |
129 expected_source = os.path.join(os.path.dirname(__file__), '..') | 129 expected_source = os.path.join(os.path.dirname(__file__), '..') |
130 else: | 130 else: |
131 expected_source = charm_source | 131 expected_source = charm_source |
132 deploy.setup_repository.reset_mock() | 132 deploy.setup_repository.reset_mock() |
133 unit_info = juju_deploy( | 133 unit_info = juju_deploy( |
134 self.charm, service_name=service_name, options=options, | 134 self.charm, service_name=service_name, options=options, |
135 force_machine=force_machine, charm_source=charm_source, | 135 force_machine=force_machine, charm_source=charm_source, |
136 series=series) | 136 series=series) |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 command = self.call_deploy() | 196 command = self.call_deploy() |
197 service_name = command[-1] | 197 service_name = command[-1] |
198 self.assertEqual(self.charm, service_name) | 198 self.assertEqual(self.charm, service_name) |
199 | 199 |
200 def test_service_name(self): | 200 def test_service_name(self): |
201 # A customized service name can be provided and it is passed to Juju as | 201 # A customized service name can be provided and it is passed to Juju as |
202 # the last argument. | 202 # the last argument. |
203 command = self.call_deploy(service_name='my-service') | 203 command = self.call_deploy(service_name='my-service') |
204 service_name = command[-1] | 204 service_name = command[-1] |
205 self.assertEqual('my-service', service_name) | 205 self.assertEqual('my-service', service_name) |
OLD | NEW |