def test_request_content(self):
     s = set()
     n = Node()
     n.address = "1"
     n.services = ["service"]
     s.add(n)
     self.assertEqual(self.marco.request_for("deployer").pop().address, n.address)
Esempio n. 2
0
 def test_discover(self):
     self.marco.socket_mcast.recvfrom = MagicMock(side_effect=[(bytes("{\"Command\":\"Polo\"}"), ('1.1.1.1', 1339)), socket.timeout])
     #self.marco.socket_mcast.recvfrom.return_value = (bytes("{\"Command\":\"Polo\"}"), ('1.1.1.1', 1339))
     #self.marco.socket_mcast.recvfrom.side_effect= [(bytes("{\"Command\":\"Polo\"}"), ('1.1.1.1', 1339)), socket.timeout]
     
     compare = set()
     n = Node()
     n.address = '1.1.1.1'
     compare.add(n)
     #print(self.marco.marco().pop())
     self.assertEqual(self.marco.marco().pop().address, n.address)
Esempio n. 3
0
    def test_discover_multiple(self):
        MAX = 10
        side_effects = [(bytes("{\"Command\":\"Polo\"}"), ('1.1.1.1', 1339))  for n in range(0,MAX+1) if n < MAX-2]

        side_effects.append(socket.timeout())
        self.marco.socket_mcast.recvfrom = MagicMock(side_effect=side_effects)

        n = Node()
        n.address = '1.1.1.1'

        for node in self.marco.marco():
            self.assertEqual(node.address, n.address)