def setUp(self): self.trace_entries = TraceEntries()
class TestLoadEntries(unittest.TestCase): """ Now, load all entries at once""" def setUp(self): self.trace_entries = TraceEntries() def test_missing_trace(self): """ key trace is mandatory """ with self.assertRaises(ValueError): entries = {} self.trace_entries.load_entries(entries) def test_trace_non_dict(self): """ key trace has to be a dict """ with self.assertRaises(ValueError): entries = {"trace:": 0} self.trace_entries.load_entries(entries) def test_missing_switch(self): """ key trace/switch is mandatory """ with self.assertRaises(ValueError): entries = {'trace': {}} self.trace_entries.load_entries(entries) def test_missing_dpid(self): """ key trace/switch is mandatory """ with self.assertRaises(ValueError): dpid = {} switch = {"switch": dpid} entries = {"trace": switch} self.trace_entries.load_entries(entries) def test_missing_in_port(self): """ key trace/switch is mandatory """ with self.assertRaises(ValueError): dpid = {"dpid": 'a'} switch = {"switch": dpid} entries = {"trace": switch} self.trace_entries.load_entries(entries) def test_missing_eth(self): """ key trace/switch is mandatory """ with self.assertRaises(ValueError): eth = 0 dpid = {"dpid": 'a', "in_port": 1} switch = {"switch": dpid, "eth": eth} entries = {"trace": switch} self.trace_entries.load_entries(entries) def test_minimally_correct(self): """ key trace/switch is mandatory """ eth = {"dl_vlan": 100} dpid = {"dpid": 'a', "in_port": 1} switch = {"switch": dpid, "eth": eth} entries = {"trace": switch} self.trace_entries.load_entries(entries)