зеркало из https://github.com/microsoft/azure-cli.git
Added simple unit test for minmaxvalue
This commit is contained in:
Родитель
124d058c63
Коммит
8b60159735
|
@ -37,6 +37,7 @@
|
|||
<Compile Include="azure\cli\extensions\__init__.py" />
|
||||
<Compile Include="azure\cli\main.py" />
|
||||
<Compile Include="azure\cli\tests\test_add_resourcegroup_transform.py" />
|
||||
<Compile Include="command_modules\azure-cli-vm\azure\cli\command_modules\vm\tests\test_custom_vm_commands.py" />
|
||||
<Compile Include="command_modules\azure-cli-resource\azure\cli\command_modules\resource\tests\test_api_check.py">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
|
|
|
@ -46,4 +46,7 @@ def main(args, file=sys.stdout): #pylint: disable=redefined-builtin
|
|||
return ex.args[1] if len(ex.args) >= 2 else -1
|
||||
except KeyboardInterrupt:
|
||||
return -1
|
||||
except Exception as ex:
|
||||
logger.error(ex)
|
||||
return -1
|
||||
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
import json
|
||||
import unittest
|
||||
from azure.cli.command_modules.vm.custom import MinMaxValue
|
||||
|
||||
class Test_Vm_Custom(unittest.TestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
pass
|
||||
|
||||
def test_custom_minmax(self):
|
||||
validator = MinMaxValue(1, 3)
|
||||
self.assertEqual(1, validator(1))
|
||||
self.assertEqual(2, validator(2))
|
||||
self.assertEqual(3, validator(3))
|
||||
self.assertEqual(1, validator('1'))
|
||||
self.assertEqual(2, validator('2'))
|
||||
self.assertEqual(3, validator('3'))
|
||||
with self.assertRaises(ValueError):
|
||||
validator(0)
|
||||
with self.assertRaises(ValueError):
|
||||
validator('0')
|
||||
with self.assertRaises(ValueError):
|
||||
validator(4)
|
||||
with self.assertRaises(ValueError):
|
||||
validator('4')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
Загрузка…
Ссылка в новой задаче