def test(self, hof): inst = SCIONPath() data = create_mock(["pop"]) inst._ofs = create_mock(["set"]) hof.side_effect = ["hof0", "hof1", "hof2"] # Call inst._parse_hofs(data, "label", 3) # Tests assert_these_calls(data.pop, [call(hof.LEN)] * 3) inst._ofs.set.assert_called_once_with("label", ["hof0", "hof1", "hof2"])
def test_full(self, raw): inst = SCIONPath() inst._parse_iof = create_mock() inst._parse_hofs = create_mock() inst._init_of_idxs = create_mock() iof_list = [] for i in 2, 4, 6: iof = create_mock(["hops", "shortcut"]) iof.hops = i iof.shortcut = False iof_list.append(iof) inst._parse_iof.side_effect = iof_list data = create_mock() data.side_effect = ("A IOF", "A HOFS", "B IOF", "B HOFS", "C IOF", "C HOFS") raw.return_value = data # Call inst._parse("data") # Tests assert_these_calls(inst._parse_iof, [ call(data, inst.A_IOF), call(data, inst.B_IOF), call(data, inst.C_IOF) ]) assert_these_calls(inst._parse_hofs, [ call(data, inst.A_HOFS, 2), call(data, inst.B_HOFS, 4), call(data, inst.C_HOFS, 6) ]) inst._init_of_idxs.assert_called_once_with()