~canonical-platform-qa/ubuntu-system-tests/systemd_support

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/selftests/test_commands.py

  • Committer: Santiago Baldassin
  • Date: 2016-10-14 13:48:27 UTC
  • mfrom: (471.1.3 trunk)
  • Revision ID: santiago.baldassin@canonical.com-20161014134827-nsn2g96y48vqu9k5
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
164
164
        mock_ssh_config_commands.assert_called_once_with()
165
165
 
166
166
 
 
167
@mock.patch('ubuntu_system_tests.host.commands._validate_ppas',
 
168
            return_value=[commands.Ppa(
 
169
                'ppa:user/name',
 
170
                'http://ppa.launchpad.net/owner/name/dist/dists')])
167
171
class SetupCommandTestCase(ConfigBaseTestCase):
168
172
 
169
173
    def setUp(self):
170
174
        super().setUp()
171
175
        self.config_stack = config.UbuntuSystemTestsConfig()
172
176
 
173
 
    def test_ppa_setup_commands_set_image_readwrite(self):
 
177
    def test_ppa_setup_commands_set_image_readwrite(
 
178
            self, mock_validate_ppas):
174
179
        self.set_config_values()
175
180
        self.assertIn(
176
181
            'mount -o remount,rw /',
178
183
                self.config_stack, config.KEY_DEFAULT))
179
184
        )
180
185
 
181
 
    def test_ppa_setup_commands_used_in_adt_setup(self):
 
186
    def test_ppa_setup_commands_used_in_adt_setup(
 
187
            self, mock_validate_ppas):
182
188
        self.set_config_values()
183
189
        command = commands.build_adt_run_setup_command(
184
190
            self.config_stack, config.KEY_DEFAULT)
185
191
        command = ' '.join(command)
186
192
 
187
193
        run_arguments, _ = command.split('---')
188
 
        self.assertIn(
189
 
            'apt-add-repository -y ppa:canonical-platform-qa',
190
 
            run_arguments
191
 
        )
 
194
        ppa_cmd = 'apt-add-repository -y {}'.format(
 
195
            mock_validate_ppas.return_value[0].id)
 
196
        self.assertIn(ppa_cmd, run_arguments)
192
197
 
193
 
    def test_setup_commands_install_testability_libs(self):
 
198
    def test_setup_commands_install_testability_libs(
 
199
            self, mock_validate_ppas):
194
200
        self.set_config_values()
195
201
        command = commands.build_adt_run_setup_command(
196
202
            self.config_stack, config.KEY_DEFAULT)
201
207
                'qttestability-autopilot')
202
208
        )
203
209
 
204
 
    def test_setting_fs_rw_is_conditional_on_current_state(self):
 
210
    def test_setting_fs_rw_is_conditional_on_current_state(
 
211
            self, mock_validate_ppas):
205
212
        self.assertIn(
206
213
            commands._get_is_fs_ro_command(), commands._get_fs_rw_command())
207
214
 
208
 
    def test_setting_fs_ro_is_conditional_on_current_state(self):
 
215
    def test_setting_fs_ro_is_conditional_on_current_state(
 
216
            self, mock_validate_ppas):
209
217
        command = commands._get_fs_ro_setup_command()
210
218
        check_any_item_in_list_contains_value(
211
219
            command, commands._get_is_fs_rw_command())
212
220
 
213
 
    def test_enabling_verbose_option(self):
 
221
    def test_enabling_verbose_option(self, mock_validate_ppas):
214
222
        self.set_config_values()
215
223
        command = commands.build_adt_run_setup_command(
216
224
            self.config_stack, config.KEY_DEFAULT, verbose=True)
217
225
        self.assertTrue(check_any_item_in_list_contains_value(command, '-ddd'))
218
226
 
219
 
    def test_verbose_disabled_by_default(self):
 
227
    def test_verbose_disabled_by_default(self, mock_validate_ppas):
220
228
        self.set_config_values()
221
229
        command = commands.build_adt_run_setup_command(
222
230
            self.config_stack, config.KEY_DEFAULT)
225
233
 
226
234
    @mock.patch('ubuntu_system_tests.host.debian.get_dependencies',
227
235
                return_value=['dep1'])
228
 
    def test_cache_deps_installs_apt_cacher(self, mock_get_dependencies):
 
236
    def test_cache_deps_installs_apt_cacher(
 
237
            self, mock_get_dependencies, mock_validate_ppas):
229
238
        self.set_config_values()
230
239
        command = commands.build_adt_run_setup_command(
231
240
            self.config_stack, config.KEY_DEFAULT, cache_deps=True)
236
245
        mock_get_dependencies.assert_called_once_with(
237
246
            commands.TESTS_UST_DEFAULT)
238
247
 
239
 
    def test_default_no_apt_cacher_install(self):
 
248
    def test_default_no_apt_cacher_install(self, mock_validate_ppas):
240
249
        self.set_config_values()
241
250
        command = commands.build_adt_run_setup_command(
242
251
            self.config_stack, config.KEY_DEFAULT)
245
254
 
246
255
    @mock.patch('ubuntu_system_tests.host.debian.get_dependencies')
247
256
    def test_install_tests_adds_extra_dependencies(
248
 
            self, mock_get_dependencies):
 
257
            self, mock_get_dependencies, mock_validate_ppas):
249
258
        self.set_config_values()
250
259
        mock_get_dependencies.return_value = ['test-dep-1', 'test-dep-2']
251
260
        command = commands.build_adt_run_setup_command(