|
4 | 4 |
|
5 | 5 | :license: MIT, see LICENSE for more details.
|
6 | 6 | """
|
7 |
| -from SoftLayer import exceptions |
| 7 | +from SoftLayer.CLI import exceptions |
| 8 | +from SoftLayer import SoftLayerAPIError |
8 | 9 | from SoftLayer import testing
|
9 | 10 |
|
| 11 | + |
10 | 12 | import json
|
11 | 13 | import mock
|
12 | 14 |
|
@@ -48,7 +50,7 @@ def test_volume_set_lun_id_in_range_missing_value(self):
|
48 | 50 | def test_volume_set_lun_id_not_in_range(self):
|
49 | 51 | value = '-1'
|
50 | 52 | lun_mock = self.set_mock('SoftLayer_Network_Storage', 'createOrUpdateLunId')
|
51 |
| - lun_mock.side_effect = exceptions.SoftLayerAPIError( |
| 53 | + lun_mock.side_effect = SoftLayerAPIError( |
52 | 54 | 'SoftLayer_Exception_Network_Storage_Iscsi_InvalidLunId',
|
53 | 55 | 'The LUN ID specified is out of the valid range: %s [min: 0 max: 4095]' % (value))
|
54 | 56 | result = self.run_command('block volume-set-lun-id 1234 42'.split())
|
@@ -496,8 +498,18 @@ def test_replicant_failover(self):
|
496 | 498 | '--replicant-id=5678'])
|
497 | 499 |
|
498 | 500 | self.assert_no_fail(result)
|
499 |
| - self.assertEqual('Failover to replicant is now in progress.\n', |
500 |
| - result.output) |
| 501 | + self.assertEqual('Failover to replicant is now in progress.\n', result.output) |
| 502 | + |
| 503 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 504 | + @mock.patch('SoftLayer.BlockStorageManager.disaster_recovery_failover_to_replicant') |
| 505 | + def test_disaster_recovery_failover(self, disaster_recovery_failover_mock, confirm_mock): |
| 506 | + confirm_mock.return_value = True |
| 507 | + disaster_recovery_failover_mock.return_value = True |
| 508 | + result = self.run_command(['block', 'disaster-recovery-failover', '12345678', |
| 509 | + '--replicant-id=5678']) |
| 510 | + |
| 511 | + self.assert_no_fail(result) |
| 512 | + self.assertIn('Disaster Recovery Failover to replicant is now in progress.\n', result.output) |
501 | 513 |
|
502 | 514 | def test_replication_locations(self):
|
503 | 515 | result = self.run_command(['block', 'replica-locations', '1234'])
|
@@ -558,6 +570,16 @@ def test_replicant_failover_unsuccessful(self, failover_mock):
|
558 | 570 | self.assertEqual('Failover operation could not be initiated.\n',
|
559 | 571 | result.output)
|
560 | 572 |
|
| 573 | + @mock.patch('SoftLayer.CLI.formatting.confirm') |
| 574 | + def test_disaster_recovery_failover_aborted(self, confirm_mock): |
| 575 | + confirm_mock.return_value = False |
| 576 | + |
| 577 | + result = self.run_command(['block', 'disaster-recovery-failover', '12345678', |
| 578 | + '--replicant-id=5678']) |
| 579 | + |
| 580 | + self.assertEqual(result.exit_code, 2) |
| 581 | + self.assertIsInstance(result.exception, exceptions.CLIAbort) |
| 582 | + |
561 | 583 | def test_replicant_failback(self):
|
562 | 584 | result = self.run_command(['block', 'replica-failback', '12345678'])
|
563 | 585 |
|
|
0 commit comments