2020-01-09 22:23:08 +00:00
|
|
|
import netaddr
|
|
|
|
|
2019-04-30 07:31:47 +01:00
|
|
|
from core import utils
|
2018-08-17 16:25:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
class TestUtils:
|
|
|
|
def test_make_tuple_fromstr(self):
|
|
|
|
# given
|
|
|
|
no_args = "()"
|
|
|
|
one_arg = "('one',)"
|
|
|
|
two_args = "('one', 'two')"
|
2023-02-03 23:53:44 +00:00
|
|
|
unicode_args = "('one', 'two', 'three')"
|
2018-08-17 16:25:57 +01:00
|
|
|
|
|
|
|
# when
|
|
|
|
no_args = utils.make_tuple_fromstr(no_args, str)
|
|
|
|
one_arg = utils.make_tuple_fromstr(one_arg, str)
|
|
|
|
two_args = utils.make_tuple_fromstr(two_args, str)
|
|
|
|
unicode_args = utils.make_tuple_fromstr(unicode_args, str)
|
|
|
|
|
|
|
|
# then
|
|
|
|
assert no_args == ()
|
|
|
|
assert len(one_arg) == 1
|
|
|
|
assert len(two_args) == 2
|
|
|
|
assert len(unicode_args) == 3
|
2020-01-09 22:23:08 +00:00
|
|
|
|
|
|
|
def test_random_mac(self):
|
|
|
|
value = utils.random_mac()
|
|
|
|
assert netaddr.EUI(value) is not None
|