|
15 | 15 |
|
16 | 16 | class VirtTests(testing.TestCase): |
17 | 17 |
|
| 18 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 19 | + def test_rescue_vs(self, confirm_mock): |
| 20 | + confirm_mock.return_value = True |
| 21 | + result = self.run_command(['vs', 'rescue', '100']) |
| 22 | + |
| 23 | + self.assert_no_fail(result) |
| 24 | + |
| 25 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 26 | + def test_rescue_vs_no_confirm(self, confirm_mock): |
| 27 | + confirm_mock.return_value = False |
| 28 | + result = self.run_command(['vs', 'rescue', '100']) |
| 29 | + |
| 30 | + self.assertEqual(result.exit_code, 2) |
| 31 | + |
| 32 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 33 | + def test_reboot_vs_default(self, confirm_mock): |
| 34 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'rebootDefault') |
| 35 | + mock.return_value = 'true' |
| 36 | + confirm_mock.return_value = True |
| 37 | + result = self.run_command(['vs', 'reboot', '100']) |
| 38 | + |
| 39 | + self.assert_no_fail(result) |
| 40 | + |
| 41 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 42 | + def test_reboot_vs_no_confirm(self, confirm_mock): |
| 43 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'rebootDefault') |
| 44 | + mock.return_value = 'true' |
| 45 | + confirm_mock.return_value = False |
| 46 | + result = self.run_command(['vs', 'reboot', '100']) |
| 47 | + |
| 48 | + self.assertEqual(result.exit_code, 2) |
| 49 | + |
| 50 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 51 | + def test_reboot_vs_soft(self, confirm_mock): |
| 52 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'rebootSoft') |
| 53 | + mock.return_value = 'true' |
| 54 | + confirm_mock.return_value = True |
| 55 | + |
| 56 | + result = self.run_command(['vs', 'reboot', '--soft', '100']) |
| 57 | + |
| 58 | + self.assert_no_fail(result) |
| 59 | + |
| 60 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 61 | + def test_reboot_vs_hard(self, confirm_mock): |
| 62 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'rebootHard') |
| 63 | + mock.return_value = 'true' |
| 64 | + confirm_mock.return_value = True |
| 65 | + result = self.run_command(['vs', 'reboot', '--hard', '100']) |
| 66 | + |
| 67 | + self.assert_no_fail(result) |
| 68 | + |
| 69 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 70 | + def test_power_vs_off_soft(self, confirm_mock): |
| 71 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'powerOffSoft') |
| 72 | + mock.return_value = 'true' |
| 73 | + confirm_mock.return_value = True |
| 74 | + |
| 75 | + result = self.run_command(['vs', 'power-off', '100']) |
| 76 | + |
| 77 | + self.assert_no_fail(result) |
| 78 | + |
| 79 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 80 | + def test_power_off_vs_no_confirm(self, confirm_mock): |
| 81 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'powerOffSoft') |
| 82 | + mock.return_value = 'true' |
| 83 | + confirm_mock.return_value = False |
| 84 | + |
| 85 | + result = self.run_command(['vs', 'power-off', '100']) |
| 86 | + |
| 87 | + self.assertEqual(result.exit_code, 2) |
| 88 | + |
| 89 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 90 | + def test_power_off_vs_hard(self, confirm_mock): |
| 91 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'powerOff') |
| 92 | + mock.return_value = 'true' |
| 93 | + confirm_mock.return_value = True |
| 94 | + |
| 95 | + result = self.run_command(['vs', 'power-off', '--hard', '100']) |
| 96 | + |
| 97 | + self.assert_no_fail(result) |
| 98 | + |
| 99 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 100 | + def test_power_on_vs(self, confirm_mock): |
| 101 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'powerOn') |
| 102 | + mock.return_value = 'true' |
| 103 | + confirm_mock.return_value = True |
| 104 | + |
| 105 | + result = self.run_command(['vs', 'power-on', '100']) |
| 106 | + |
| 107 | + self.assert_no_fail(result) |
| 108 | + |
| 109 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 110 | + def test_pause_vs(self, confirm_mock): |
| 111 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'pause') |
| 112 | + mock.return_value = 'true' |
| 113 | + confirm_mock.return_value = True |
| 114 | + |
| 115 | + result = self.run_command(['vs', 'pause', '100']) |
| 116 | + |
| 117 | + self.assert_no_fail(result) |
| 118 | + |
| 119 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 120 | + def test_pause_vs_no_confirm(self, confirm_mock): |
| 121 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'pause') |
| 122 | + mock.return_value = 'true' |
| 123 | + confirm_mock.return_value = False |
| 124 | + |
| 125 | + result = self.run_command(['vs', 'pause', '100']) |
| 126 | + |
| 127 | + self.assertEqual(result.exit_code, 2) |
| 128 | + |
| 129 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 130 | + def test_resume_vs(self, confirm_mock): |
| 131 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'resume') |
| 132 | + mock.return_value = 'true' |
| 133 | + confirm_mock.return_value = True |
| 134 | + |
| 135 | + result = self.run_command(['vs', 'resume', '100']) |
| 136 | + |
| 137 | + self.assert_no_fail(result) |
| 138 | + |
18 | 139 | def test_list_vs(self): |
19 | 140 | result = self.run_command(['vs', 'list', '--tag=tag']) |
20 | 141 |
|
@@ -662,3 +783,21 @@ def test_going_ready(self, _sleep): |
662 | 783 | result = self.run_command(['vs', 'ready', '100', '--wait=100']) |
663 | 784 | self.assert_no_fail(result) |
664 | 785 | self.assertEqual(result.output, '"READY"\n') |
| 786 | + |
| 787 | + @mock.patch('SoftLayer.CLI.formatting.no_going_back') |
| 788 | + def test_reload(self, confirm_mock): |
| 789 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'reloadCurrentOperatingSystemConfguration') |
| 790 | + confirm_mock.return_value = True |
| 791 | + mock.return_value = 'true' |
| 792 | + |
| 793 | + result = self.run_command(['vs', 'reload', '--postinstall', '100', '--key', '100', '--image', '100', '100']) |
| 794 | + self.assert_no_fail(result) |
| 795 | + |
| 796 | + @mock.patch('SoftLayer.CLI.formatting.no_going_back') |
| 797 | + def test_reload_no_confirm(self, confirm_mock): |
| 798 | + mock = self.set_mock('SoftLayer_Virtual_Guest', 'reloadCurrentOperatingSystemConfiguration') |
| 799 | + confirm_mock.return_value = False |
| 800 | + mock.return_value = 'false' |
| 801 | + |
| 802 | + result = self.run_command(['vs', 'reload', '--postinstall', '100', '--key', '100', '--image', '100', '100']) |
| 803 | + self.assertEqual(result.exit_code, 2) |
0 commit comments