Skip to content

Commit 17aa0d2

Browse files
Merge pull request #1970 from ramkishor-ch/master
#1954
2 parents 23fadb8 + af08140 commit 17aa0d2

File tree

1 file changed

+104
-0
lines changed

1 file changed

+104
-0
lines changed

tests/CLI/modules/block_tests.py

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,110 @@ def test_snapshot_cancel(self):
432432
self.assert_called_with('SoftLayer_Billing_Item', 'cancelItem',
433433
args=(False, True, None))
434434

435+
@mock.patch('SoftLayer.BlockStorageManager.set_volume_snapshot_notification')
436+
def test_block_snapshot_set_notify_status(self, set_s_notification):
437+
set_s_notification.return_value = True
438+
result = self.run_command(['block', 'snapshot-set-notification', '1234', '--enable'])
439+
440+
self.assert_no_fail(result)
441+
self.assertEqual('Snapshots space usage threshold warning notification has bee set to'
442+
' True for volume 1234\n', result.output)
443+
444+
def test_block_snapshot_cancel_immediate(self):
445+
result = self.run_command(['--really',
446+
'block', 'snapshot-cancel', '--immediate', '1234'])
447+
448+
self.assert_no_fail(result)
449+
self.assertEqual('Block volume with id 1234 has been marked'
450+
' for immediate snapshot cancellation\n', result.output)
451+
452+
@mock.patch('SoftLayer.BlockStorageManager.cancel_snapshot_space')
453+
def test_block_snapshot_unable_cancel(self, cancel_snapshot_space):
454+
cancel_snapshot_space.return_value = False
455+
result = self.run_command(['--really',
456+
'block', 'snapshot-cancel', '1234'])
457+
458+
self.assert_no_fail(result)
459+
self.assertEqual('Unable to cancel snapshot space for block volume 1234\n', result.output)
460+
461+
@mock.patch('SoftLayer.CLI.formatting.no_going_back')
462+
def test_snapshot_cancel_aborted(self, no_going_back):
463+
no_going_back.return_value = False
464+
result = self.run_command(['block', 'snapshot-cancel', '1234'])
465+
self.assertEqual(result.exit_code, 2)
466+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
467+
468+
def test_snapshot_delete(self):
469+
result = self.run_command(['--really',
470+
'block', 'snapshot-delete', '1234'])
471+
self.assert_no_fail(result)
472+
473+
def test_block_snapshot_disable_not_in_schedule_type(self):
474+
result = self.run_command(['block', 'snapshot-disable', '12345678',
475+
'--schedule-type=ABCD'])
476+
self.assertEqual(result.exit_code, 2)
477+
self.assertEqual(result.exception.message, "--schedule-type must be INTERVAL, HOURLY, DAILY, or WEEKLY")
478+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
479+
480+
def test_block_snapshot_enable_not_in_schedule_type(self):
481+
result = self.run_command(['block', 'snapshot-enable', '12345678',
482+
'--schedule-type=ZYXW', '--minute=10',
483+
'--retention-count=5'])
484+
self.assertEqual(result.exit_code, 2)
485+
self.assertEqual(result.exception.message, "--schedule-type must be INTERVAL, HOURLY, DAILY,or WEEKLY,"
486+
" not ZYXW")
487+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
488+
489+
def test_block_snapshot_enable_retention_count(self):
490+
result = self.run_command(['block', 'snapshot-enable', '12345678',
491+
'--schedule-type=INTERVAL', '--minute=-1',
492+
'--retention-count=5'])
493+
self.assertEqual(result.exit_code, 2)
494+
self.assertEqual(result.exception.message, "--minute value must be between 30 and 59")
495+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
496+
497+
def test_block_snapshot_enable_minute(self):
498+
result = self.run_command(['block', 'snapshot-enable', '12345678',
499+
'--schedule-type=HOURLY', '--minute=-1',
500+
'--retention-count=5'])
501+
self.assertEqual(result.exit_code, 2)
502+
self.assertEqual(result.exception.message, "--minute value must be between 0 and 59")
503+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
504+
505+
def test_block_snapshot_enable_hour(self):
506+
result = self.run_command(['block', 'snapshot-enable', '12345678',
507+
'--schedule-type=DAILY', '--hour=-1',
508+
'--retention-count=5'])
509+
self.assertEqual(result.exit_code, 2)
510+
self.assertEqual(result.exception.message, "--hour value must be between 0 and 23")
511+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
512+
513+
def test_block_snapshot_enable_day_of_week(self):
514+
result = self.run_command(['block', 'snapshot-enable', '12345678',
515+
'--schedule-type=WEEKLY', '--day-of-week=EVERDAY',
516+
'--retention-count=5'])
517+
self.assertEqual(result.exit_code, 2)
518+
self.assertEqual(result.exception.message, "--day_of_week value must be a valid day (ex: SUNDAY)")
519+
self.assertIsInstance(result.exception, exceptions.CLIAbort)
520+
521+
def test_snapshot_order_order_iops(self):
522+
result = self.run_command(['block', 'snapshot-order', '1234',
523+
'--size=10', '--tier=0.25', '--iops=1'])
524+
525+
self.assertEqual(result.exit_code, 2)
526+
self.assertEqual(result.exception.message, "Argument Error: Invalid value for '--iops' / '-i': '1' is not one"
527+
" of between 100 and 6000.")
528+
self.assertIsInstance(result.exception, exceptions.ArgumentError)
529+
530+
def test_snapshot_order_order_iops_100(self):
531+
result = self.run_command(['block', 'snapshot-order', '1234',
532+
'--size=10', '--tier=0.25', '--iops=101'])
533+
534+
self.assertEqual(result.exit_code, 2)
535+
self.assertEqual(result.exception.message, "Argument Error: Invalid value for '--iops' / '-i': '101' is not"
536+
" a multiple of 100.")
537+
self.assertIsInstance(result.exception, exceptions.ArgumentError)
538+
435539
def test_snapshot_restore(self):
436540
result = self.run_command(['block', 'snapshot-restore', '12345678',
437541
'--snapshot-id=87654321'])

0 commit comments

Comments
 (0)