Exemplo n.º 1
0
 def test_invalid_arguments_exit_fail(self):
     # silence writes that get to stderr
     with mock.patch('cloudinit.shell.sys.stderr'):
         exc = self.assertRaises(SystemExit,
                                 shell.main,
                                 args=['cloud-init', 'bogus_argument'])
         self.assertNotEqual(exc.code, 0)
Exemplo n.º 2
0
    def test_serial_search_strategy(self):
        def is_available(self, data_source):
            return data_source in available_sources

        sources = [mock.sentinel.first, mock.sentinel.second,
                   mock.sentinel.third, mock.sentinel.fourth]
        available_sources = [mock.sentinel.second, mock.sentinel.fourth]

        with mock.patch('cloudinit.sources.strategy.BaseSearchStrategy.'
                        'is_datasource_available', new=is_available):
            instance = strategy.SerialSearchStrategy()
            valid_sources = list(instance.search_data_sources(sources))

        self.assertEqual(available_sources, valid_sources)
Exemplo n.º 3
0
    def test_serial_search_strategy(self):
        def is_available(self, data_source):
            return data_source in available_sources

        sources = [
            mock.sentinel.first, mock.sentinel.second, mock.sentinel.third,
            mock.sentinel.fourth
        ]
        available_sources = [mock.sentinel.second, mock.sentinel.fourth]

        with mock.patch(
                'cloudinit.sources.strategy.BaseSearchStrategy.'
                'is_datasource_available',
                new=is_available):
            instance = strategy.SerialSearchStrategy()
            valid_sources = list(instance.search_data_sources(sources))

        self.assertEqual(available_sources, valid_sources)
Exemplo n.º 4
0
 def test_invalid_arguments_exit_fail(self):
     # silence writes that get to stderr
     with mock.patch('cloudinit.shell.sys.stderr'):
         exc = self.assertRaises(
             SystemExit, shell.main, args=['cloud-init', 'bogus_argument'])
         self.assertNotEqual(exc.code, 0)
Exemplo n.º 5
0
 def test_help_exits_success(self):
     with mock.patch('cloudinit.shell.sys.stdout'):
         exc = self.assertRaises(
             SystemExit, shell.main, args=['cloud-init', '--help'])
         self.assertEqual(exc.code, 0)