mirror of
https://github.com/valitydev/salt.git
synced 2024-11-08 01:18:58 +00:00
Actually testing parted
called_once_with didn't work, changed to assert_called_once_with
This commit is contained in:
parent
1bee2a2d89
commit
70e4062cf9
@ -73,37 +73,33 @@ class PartedTestCase(TestCase):
|
|||||||
|
|
||||||
def test_probe_wo_args(self):
|
def test_probe_wo_args(self):
|
||||||
parted.probe()
|
parted.probe()
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('partprobe -- ')
|
||||||
['partprobe'], python_shell=False)
|
|
||||||
|
|
||||||
def test_probe_w_single_arg(self):
|
def test_probe_w_single_arg(self):
|
||||||
parted.probe("/dev/sda")
|
parted.probe("/dev/sda")
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda')
|
||||||
['partprobe', '/dev/sda'], python_shell=False)
|
|
||||||
|
|
||||||
def test_probe_w_multiple_args(self):
|
def test_probe_w_multiple_args(self):
|
||||||
parted.probe('/dev/sda', '/dev/sdb')
|
parted.probe('/dev/sda', '/dev/sdb')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda /dev/sdb')
|
||||||
['partprobe', '/dev/sda', '/dev/sdb'], python_shell=False)
|
|
||||||
|
|
||||||
@patch('salt.utils.kwargs_warn_until')
|
@patch('salt.utils.kwargs_warn_until')
|
||||||
def test_probe_w_device_kwarg(self, *args, **kwargs):
|
def test_probe_w_device_kwarg(self, *args, **kwargs):
|
||||||
parted.probe(device="/dev/sda")
|
parted.probe(device="/dev/sda")
|
||||||
parted.salt.utils.kwargs_warn_until.called_once_with({'device': '/dev/sda'})
|
parted.salt.utils.kwargs_warn_until({'device': '/dev/sda'})
|
||||||
self.cmdrun.called_once_with(['partprobe', '/dev/sda'], python_shell=False)
|
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda')
|
||||||
|
|
||||||
@patch('salt.utils.kwargs_warn_until')
|
@patch('salt.utils.kwargs_warn_until')
|
||||||
def test_probe_w_device_kwarg_and_arg(self, *args, **kwargs):
|
def test_probe_w_device_kwarg_and_arg(self, *args, **kwargs):
|
||||||
'''device arg is concatanated with possitional args'''
|
'''device arg is concatanated with possitional args'''
|
||||||
parted.probe("/dev/sdb", device="/dev/sda")
|
parted.probe("/dev/sdb", device="/dev/sda")
|
||||||
parted.salt.utils.kwargs_warn_until.called_once_with({'device': '/dev/sda'})
|
parted.salt.utils.kwargs_warn_until({'device': '/dev/sda'})
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('partprobe -- /dev/sda /dev/sdb')
|
||||||
['partprobe', '/dev/sda', '/dev/sdb'], python_shell=False)
|
|
||||||
|
|
||||||
@patch('salt.utils.kwargs_warn_until')
|
@patch('salt.utils.kwargs_warn_until')
|
||||||
def test_probe_w_extra_kwarg(self, *args, **kwargs):
|
def test_probe_w_extra_kwarg(self, *args, **kwargs):
|
||||||
self.assertRaises(TypeError, parted.probe, foo="bar")
|
self.assertRaises(TypeError, parted.probe, foo="bar")
|
||||||
parted.salt.utils.kwargs_warn_until.called_once_with({'device': '/dev/sda'})
|
parted.salt.utils.kwargs_warn_until({'device': '/dev/sda'})
|
||||||
self.assertFalse(self.cmdrun.called)
|
self.assertFalse(self.cmdrun.called)
|
||||||
|
|
||||||
# Test part_list function
|
# Test part_list function
|
||||||
@ -113,12 +109,11 @@ class PartedTestCase(TestCase):
|
|||||||
def test_part_list(self, *args, **kwargs):
|
def test_part_list(self, *args, **kwargs):
|
||||||
'''Function should call new function and raise deprecation warning'''
|
'''Function should call new function and raise deprecation warning'''
|
||||||
parted.part_list("foo", "bar")
|
parted.part_list("foo", "bar")
|
||||||
parted.list_.called_once_with("foo", "bar")
|
parted.list_.assert_called_once_with("foo", "bar")
|
||||||
parted.salt.utils.warn_until.called_once_with(
|
parted.salt.utils.warn_until.assert_called_once_with(
|
||||||
'Beryllium',
|
'Beryllium',
|
||||||
'''The \'part_list\' function has been deprecated in favor of
|
'''The \'part_list\' function has been deprecated in favor of
|
||||||
\'list\'. Please update your code and configs to reflect
|
\'list_\'. Please update your code and configs to reflect this.''')
|
||||||
this.''')
|
|
||||||
|
|
||||||
# Test _list function
|
# Test _list function
|
||||||
|
|
||||||
@ -165,28 +160,14 @@ class PartedTestCase(TestCase):
|
|||||||
def test_list__empty_cmd_output(self):
|
def test_list__empty_cmd_output(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('empty')
|
self.cmdrun.return_value = self.parted_print_output('empty')
|
||||||
output = parted.list_('/dev/sda')
|
output = parted.list_('/dev/sda')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
expected = {'info': {}, 'partitions': {}}
|
expected = {'info': {}, 'partitions': {}}
|
||||||
self.assertEqual(output, expected)
|
self.assertEqual(output, expected)
|
||||||
|
|
||||||
def test_list__valid_unit_empty_cmd_output(self):
|
def test_list__valid_unit_empty_cmd_output(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('empty')
|
self.cmdrun.return_value = self.parted_print_output('empty')
|
||||||
output = parted.list_('/dev/sda', unit='s')
|
output = parted.list_('/dev/sda', unit='s')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda unit s print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'unit',
|
|
||||||
's',
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
expected = {'info': {}, 'partitions': {}}
|
expected = {'info': {}, 'partitions': {}}
|
||||||
self.assertEqual(output, expected)
|
self.assertEqual(output, expected)
|
||||||
|
|
||||||
@ -198,46 +179,22 @@ class PartedTestCase(TestCase):
|
|||||||
def test_list__bad_header(self):
|
def test_list__bad_header(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('bad_header')
|
self.cmdrun.return_value = self.parted_print_output('bad_header')
|
||||||
self.assertRaises(CommandExecutionError, parted.list_, '/dev/sda')
|
self.assertRaises(CommandExecutionError, parted.list_, '/dev/sda')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_list__bad_label_info(self):
|
def test_list__bad_label_info(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('bad_label_info')
|
self.cmdrun.return_value = self.parted_print_output('bad_label_info')
|
||||||
self.assertRaises(CommandExecutionError, parted.list_, '/dev/sda')
|
self.assertRaises(CommandExecutionError, parted.list_, '/dev/sda')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_list__bad_partition(self):
|
def test_list__bad_partition(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('bad_partition')
|
self.cmdrun.return_value = self.parted_print_output('bad_partition')
|
||||||
self.assertRaises(CommandExecutionError, parted.list_, '/dev/sda')
|
self.assertRaises(CommandExecutionError, parted.list_, '/dev/sda')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
|
|
||||||
def test_list__valid_cmd_output(self):
|
def test_list__valid_cmd_output(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('valid')
|
self.cmdrun.return_value = self.parted_print_output('valid')
|
||||||
output = parted.list_('/dev/sda')
|
output = parted.list_('/dev/sda')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
expected = {
|
expected = {
|
||||||
'info': {
|
'info': {
|
||||||
'logical sector': '512',
|
'logical sector': '512',
|
||||||
@ -274,15 +231,7 @@ class PartedTestCase(TestCase):
|
|||||||
def test_list__valid_unit_valid_cmd_output(self):
|
def test_list__valid_unit_valid_cmd_output(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('valid')
|
self.cmdrun.return_value = self.parted_print_output('valid')
|
||||||
output = parted.list_('/dev/sda', unit='s')
|
output = parted.list_('/dev/sda', unit='s')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda unit s print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'unit',
|
|
||||||
's',
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
expected = {
|
expected = {
|
||||||
'info': {
|
'info': {
|
||||||
'logical sector': '512',
|
'logical sector': '512',
|
||||||
@ -319,13 +268,7 @@ class PartedTestCase(TestCase):
|
|||||||
def test_list__valid_legacy_cmd_output(self):
|
def test_list__valid_legacy_cmd_output(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('valid_legacy')
|
self.cmdrun.return_value = self.parted_print_output('valid_legacy')
|
||||||
output = parted.list_('/dev/sda')
|
output = parted.list_('/dev/sda')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
expected = {
|
expected = {
|
||||||
'info': {
|
'info': {
|
||||||
'logical sector': '512',
|
'logical sector': '512',
|
||||||
@ -361,15 +304,7 @@ class PartedTestCase(TestCase):
|
|||||||
def test_list__valid_unit_valid_legacy_cmd_output(self):
|
def test_list__valid_unit_valid_legacy_cmd_output(self):
|
||||||
self.cmdrun.return_value = self.parted_print_output('valid_legacy')
|
self.cmdrun.return_value = self.parted_print_output('valid_legacy')
|
||||||
output = parted.list_('/dev/sda', unit='s')
|
output = parted.list_('/dev/sda', unit='s')
|
||||||
self.cmdrun.called_once_with(
|
self.cmdrun.assert_called_once_with('parted -m -s /dev/sda unit s print')
|
||||||
['parted',
|
|
||||||
'-m',
|
|
||||||
'-s',
|
|
||||||
'/dev/sda'
|
|
||||||
'unit',
|
|
||||||
's',
|
|
||||||
'print']
|
|
||||||
)
|
|
||||||
expected = {
|
expected = {
|
||||||
'info': {
|
'info': {
|
||||||
'logical sector': '512',
|
'logical sector': '512',
|
||||||
|
Loading…
Reference in New Issue
Block a user