Ejemplo n.º 1
0
Archivo: tests.py Proyecto: grapo/ETO
class LanTest(unittest.TestCase):
    def setUp(self):
        self.mac = Workstation(name="mac")
        self.sun = Workstation(name="sun", next_node=self.mac)
        self.link = Link(name="link", next_node=self.sun)
        self.printer = Printer(name="printer", next_node=self.link)
        self.fileserver = Fileserver(name="fileserver", next_node=self.printer)
        self.pc = Workstation(name="pc", next_node=self.fileserver)
        self.mac.next_node = self.pc

    def test_good_receiver_packet(self):
        p = Packet(content="x", receiver="sun")
        self.mac.originate(p)
        self.assertEquals(self.sun.last_packet, p)

    def test_good_path_packet(self):
        p = Packet(content="x", receiver="sun")
        self.mac.originate(p)
        self.assertEquals(self.pc.last_packet, p)

    def test_loop_in_lan(self):
        # samo to, że ta funkcja działa  świadczy o 
        # tym, że pętle w sieci są obsługiwane
        p = Packet(content="x", receiver="nobody")
        self.mac.originate(p)
        self.assertEquals(p._hopcounter, Packet.MAX_HOP)
Ejemplo n.º 2
0
Archivo: tests.py Proyecto: grapo/ETO
 def test_originate_packet(self):
     w1 = Workstation(name="w1")
     p = Packet(content="X", receiver="w2")
     w1.originate(p)
     self.assertEquals(p.sender, w1.name)