Пример #1
0
    def test__get_kernel_params_kernel_cmdline(self, read_params_mock):

        expected_params = {'a': 'b'}
        read_params_mock.return_value = expected_params
        returned_params = agent_cmd._get_kernel_params()
        read_params_mock.assert_called_once_with('/proc/cmdline')
        self.assertEqual(expected_params, returned_params)
Пример #2
0
    def test__get_kernel_params_kernel_cmdline(self, read_params_mock):

        expected_params = {'a': 'b'}
        read_params_mock.return_value = expected_params
        returned_params = agent_cmd._get_kernel_params()
        read_params_mock.assert_called_once_with('/proc/cmdline')
        self.assertEqual(expected_params, returned_params)
Пример #3
0
 def test__get_kernel_params(self, open_mock):
     kernel_line = 'api-url=http://localhost:9999 baz foo=bar\n'
     open_mock.return_value.__enter__ = lambda s: s
     open_mock.return_value.__exit__ = mock.Mock()
     read_mock = open_mock.return_value.read
     read_mock.return_value = kernel_line
     params = agent_cmd._get_kernel_params()
     self.assertEqual(params['api-url'], 'http://localhost:9999')
     self.assertEqual(params['foo'], 'bar')
     self.assertFalse('baz' in params)
Пример #4
0
    def test__get_kernel_params_vmedia(self, read_params_mock,
                                       get_vmedia_params_mock):

        kernel_params = {'boot_method': 'vmedia'}
        vmedia_params = {'a': 'b'}
        expected_params = dict(kernel_params.items() + vmedia_params.items())
        read_params_mock.return_value = kernel_params
        get_vmedia_params_mock.return_value = vmedia_params

        returned_params = agent_cmd._get_kernel_params()
        read_params_mock.assert_called_once_with('/proc/cmdline')
        self.assertEqual(expected_params, returned_params)
Пример #5
0
    def test__get_kernel_params_vmedia(self, read_params_mock,
                                       get_vmedia_params_mock):

        kernel_params = {'boot_method': 'vmedia'}
        vmedia_params = {'a': 'b'}
        expected_params = dict(kernel_params.items() +
                               vmedia_params.items())
        read_params_mock.return_value = kernel_params
        get_vmedia_params_mock.return_value = vmedia_params

        returned_params = agent_cmd._get_kernel_params()
        read_params_mock.assert_called_once_with('/proc/cmdline')
        self.assertEqual(expected_params, returned_params)
Пример #6
0
 def test__get_kernel_params_fail(self, logger_mock, open_mock):
     open_mock.side_effect = Exception
     params = agent_cmd._get_kernel_params()
     self.assertEqual(params, {})