forked from uncloud/uncloud
Wrote first unit tests
This commit is contained in:
parent
d8a465bca4
commit
1ca2f8670d
3 changed files with 42 additions and 0 deletions
5
.gitlab-ci.yml
Normal file
5
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
image: python:3
|
||||||
|
|
||||||
|
pythonTests:
|
||||||
|
script:
|
||||||
|
- python -m unittest -v test/test_mac_local.py
|
0
test/__init__.py
Normal file
0
test/__init__.py
Normal file
37
test/test_mac_local.py
Normal file
37
test/test_mac_local.py
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
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()
|
Loading…
Reference in a new issue