forked from uncloud/uncloud
38 lines
1.3 KiB
Python
38 lines
1.3 KiB
Python
|
import unittest
|
||
|
from unittest.mock import Mock
|
||
|
|
||
|
from uncloud.hack.mac import MAC
|
||
|
from uncloud import UncloudException
|
||
|
|
||
|
class TestMacLocal(unittest.TestCase):
|
||
|
def setUp(self):
|
||
|
self.config = Mock()
|
||
|
self.config.arguments = {"no_db":True}
|
||
|
self.mac = MAC(self.config)
|
||
|
self.mac.create()
|
||
|
|
||
|
def testMacInt(self):
|
||
|
self.assertEqual(self.mac.__int__(), int("0x420000000001",0), "wrong first MAC index")
|
||
|
|
||
|
def testMacRepr(self):
|
||
|
self.assertEqual(self.mac.__repr__(), '420000000001', "wrong first MAC index")
|
||
|
|
||
|
def testMacStr(self):
|
||
|
self.assertEqual(self.mac.__str__(), '42:00:00:00:00:01', "wrong first MAC index")
|
||
|
|
||
|
def testValidationRaise(self):
|
||
|
with self.assertRaises(UncloudException):
|
||
|
self.mac.validate_mac("2")
|
||
|
|
||
|
def testValidation(self):
|
||
|
self.assertTrue(self.mac.validate_mac("42:00:00:00:00:01"), "Validation of a given MAC not working properly")
|
||
|
|
||
|
def testNextMAC(self):
|
||
|
self.mac.create()
|
||
|
self.assertEqual(self.mac.__repr__(), '420000000001', "wrong second MAC index")
|
||
|
self.assertEqual(self.mac.__int__(), int("0x420000000001",0), "wrong second MAC index")
|
||
|
self.assertEqual(self.mac.__str__(), '42:00:00:00:00:01', "wrong second MAC index")
|
||
|
|
||
|
if __name__ == '__main__':
|
||
|
unittest.main()
|