Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 88 additions & 0 deletions tests/test_madmac.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,91 @@ def test_validate_MAC_TypeError(self):

def test_validate_MAC_ValueError(self):
self.assertFalse(madmac.validate_mac(None))

def test_mac_generator(self):
self.assertIsNotNone(MacGenerator())

def test_mac_generator_normalize_oui(self):
mc = MacGenerator(oui="AA:BB:CC", delimiter=" ")
self.assertEqual(mc.normalize_oui(), "AA BB CC")

def test_mac_generator_pick_random_int(self):
mc = MacGenerator()
self.assertIs(int, type(mc._pick_random_int()))

def test_mac_generator_prepare_oui(self):
mc = MacGenerator()
mc._prepare_oui()
self.assertIs(str, type(mc.oui))

def test_mac_generator_prepare_oui_user(self):
mc = MacGenerator(oui="aa:bb:cc")
mc._prepare_oui()
self.assertEqual("aabbcc", mc.oui)

def test_mac_generator_prepare_oui_ValueError(self):
mc = MacGenerator(oui="xx:yy:zz")
self.assertRaises(ValueError, mc._prepare_oui)

def test_mac_generator_prepare_start_address(self):
mc = MacGenerator()
mc._prepare_start_address()
self.assertIs(int, type(mc.i_start))

def test_mac_generator_prepare_start_address_user(self):
mc = MacGenerator(start="110000")
mc._prepare_start_address()
self.assertEqual(1114112, mc.i_start)

def test_mac_generator_prepare_start_address_ValueError(self):
mc = MacGenerator(start="1100YY")
self.assertRaises(ValueError, mc._prepare_start_address)

def test_mac_generator_prepare_stop_address(self):
mc = MacGenerator()
mc._prepare_stop_address()
self.assertIs(int, type(mc.i_stop))

def test_mac_generator_prepare_stop_address_user(self):
mc = MacGenerator(start="000005", stop="000010")
mc._prepare_stop_address()
self.assertEqual(16, mc.i_stop)

def test_mac_generator_prepare_stop_address_ValueError(self):
mc = MacGenerator(stop="-10")
self.assertRaises(ValueError, mc._prepare_stop_address)

def test_mac_generator_prepare_stop_address_user_total(self):
mc = MacGenerator(total="")
self.assertRaises(ValueError, mc._prepare_stop_address)

def test_mac_generator_prepare_stop_address_UnsupportedOperation(self):
mc = MacGenerator(total="X")
self.assertRaises(UnsupportedOperation, mc._prepare_stop_address)

def test_mac_generator_prepare_stop_address_InvalidEndingAddress(self):
mc = MacGenerator(start="000005", stop="00001G")
self.assertRaises(ValueError, mc._prepare_stop_address)

def test_mac_generator_validate(self):
mc = MacGenerator()
self.assertIsNone(mc._validate())

def test_mac_generator_build(self):
mc = MacGenerator()
mc._validate()
self.assertIs(str, type(list(mc._build())[-1]))

def test_mac_generator_generate(self):
mc = MacGenerator()
self.assertIs(str, type(list(mc.generate())[-1]))

def test_handle_args(self):
fn = getattr(module, "handle_args")
self.assertIsNotNone(fn().parse_args(["-t", "1"]))

def test_main(self):
handle_args = getattr(module, "handle_args")
main = getattr(module, "main")
args = vars(handle_args().parse_args(["-t", "1"]))
self.assertIs(str, type(main(args)))