本文整理汇总了Python中SoftLayer.CLI类的典型用法代码示例。如果您正苦于以下问题:Python CLI类的具体用法?Python CLI怎么用?Python CLI使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CLI类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_init
def test_init(self):
l = cli.listing([1, 'two'], separator=':')
self.assertEqual([1, 'two'], list(l))
self.assertEqual(':', l.separator)
l = cli.listing([])
self.assertEqual(',', l.separator)
示例2: test_str
def test_str(self):
l = cli.listing([1, 'two'])
result = str(l)
self.assertEqual('1,two', result)
l = cli.listing((x for x in [1, 'two']), separator=':')
result = str(l)
self.assertEqual('1:two', result)
示例3: test_to_python
def test_to_python(self):
l = cli.listing([1, 'two'])
result = l.to_python()
self.assertEqual([1, 'two'], result)
l = cli.listing(x for x in [1, 'two'])
result = l.to_python()
self.assertEqual([1, 'two'], result)
示例4: test_transaction_status_missing
def test_transaction_status_missing(self):
b = cli.blank()
result = cli.transaction_status({
'transactionStatus': {}
})
self.assertIsInstance(result, cli.FormattedItem)
self.assertEqual(result.original, b.original)
示例5: test_do_or_die
def test_do_or_die(self, raw_input_mock):
confirmed = '37347373737'
raw_input_mock.return_value = confirmed
result = cli.no_going_back(confirmed)
self.assertTrue(result)
confirmed = None
raw_input_mock.return_value = ''
result = cli.no_going_back(confirmed)
self.assertFalse(result)
示例6: test_active_txn_missing
def test_active_txn_missing(self):
""" a dict with activeTransaction but not transactionStatus
should return blank() instead of raising an exception"""
b = cli.blank()
result = cli.active_txn({
'activeTransaction': {}
})
self.assertIsInstance(result, cli.FormattedItem)
self.assertEquals(result.original, b.original)
示例7: test_confirmation
def test_confirmation(self, raw_input_mock):
raw_input_mock.return_value = 'Y'
res = cli.confirm('Confirm?', default=False)
self.assertTrue(res)
raw_input_mock.return_value = 'N'
res = cli.confirm('Confirm?', default=False)
self.assertFalse(res)
raw_input_mock.return_value = ''
res = cli.confirm('Confirm?', default=True)
self.assertTrue(res)
示例8: test_gb
def test_gb(self):
item = cli.gb(2)
self.assertEqual(2048, item.original)
self.assertEqual('2G', item.formatted)
item = cli.gb('2')
self.assertEqual(2048, item.original)
self.assertEqual('2G', item.formatted)
item = cli.gb('2.0')
self.assertEqual(2048, item.original)
self.assertEqual('2G', item.formatted)
示例9: test_mb_to_gb
def test_mb_to_gb(self):
item = cli.mb_to_gb(1024)
self.assertEqual(1024, item.original)
self.assertEqual('1G', item.formatted)
item = cli.mb_to_gb('1024')
self.assertEqual('1024', item.original)
self.assertEqual('1G', item.formatted)
item = cli.mb_to_gb('1025.0')
self.assertEqual('1025.0', item.original)
self.assertEqual('1G', item.formatted)
self.assertRaises(ValueError, cli.mb_to_gb, '1024string')
示例10: test_do_or_die
def test_do_or_die(self, raw_input_mock):
confirmed = '37347373737'
raw_input_mock.return_value = confirmed
result = cli.no_going_back(confirmed)
self.assertTrue(result)
# no_going_back should cast int's to str()
confirmed = '4712309182309'
raw_input_mock.return_value = confirmed
result = cli.no_going_back(int(confirmed))
self.assertTrue(result)
confirmed = None
raw_input_mock.return_value = ''
result = cli.no_going_back(confirmed)
self.assertFalse(result)
示例11: test_transaction_status
def test_transaction_status(self):
result = cli.transaction_status({
'transactionStatus': {
'name': 'a',
'friendlyName': 'b'
}
})
self.assertEquals(result.original, 'a')
self.assertEquals(result.formatted, 'b')
self.assertIsInstance(result, cli.FormattedItem)