def test_magic_packet_format(self, mock_socket): fake_socket = mock.Mock(spec=socket, spec_set=True) mock_socket.return_value = fake_socket() with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: wol._send_magic_packets(task, '255.255.255.255', 9) expct_packet = (b'\xff\xff\xff\xff\xff\xffRT\x00\xcf-1RT\x00' b'\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT' b'\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00' b'\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT' b'\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1') mock_socket.return_value.sendto.assert_called_once_with( expct_packet, ('255.255.255.255', 9))
def test_magic_packet_format(self, mock_socket): fake_socket = mock.Mock(spec=socket, spec_set=True) mock_socket.return_value = fake_socket() with task_manager.acquire( self.context, self.node.uuid, shared=True) as task: wol._send_magic_packets(task, '255.255.255.255', 9) expct_packet = (b'\xff\xff\xff\xff\xff\xffRT\x00\xcf-1RT\x00' b'\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT' b'\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00' b'\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT' b'\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1RT\x00\xcf-1') mock_socket.return_value.sendto.assert_called_once_with( expct_packet, ('255.255.255.255', 9))
def test_send_magic_packets(self, mock_socket): fake_socket = mock.Mock(spec=socket, spec_set=True) mock_socket.return_value = fake_socket() obj_utils.create_test_port(self.context, uuid=uuidutils.generate_uuid(), address='aa:bb:cc:dd:ee:ff', node_id=self.node.id) with task_manager.acquire( self.context, self.node.uuid, shared=True) as task: wol._send_magic_packets(task, '255.255.255.255', 9) expected_calls = [ mock.call(), mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), mock.call().sendto(mock.ANY, ('255.255.255.255', 9)), mock.call().sendto(mock.ANY, ('255.255.255.255', 9)), mock.call().close()] fake_socket.assert_has_calls(expected_calls) self.assertEqual(1, mock_socket.call_count)
def test_send_magic_packets(self, mock_socket): fake_socket = mock.Mock(spec=socket, spec_set=True) mock_socket.return_value = fake_socket() obj_utils.create_test_port(self.context, uuid=uuidutils.generate_uuid(), address='aa:bb:cc:dd:ee:ff', node_id=self.node.id) with task_manager.acquire(self.context, self.node.uuid, shared=True) as task: wol._send_magic_packets(task, '255.255.255.255', 9) expected_calls = [ mock.call(), mock.call().setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1), mock.call().sendto(mock.ANY, ('255.255.255.255', 9)), mock.call().sendto(mock.ANY, ('255.255.255.255', 9)), mock.call().close() ] fake_socket.assert_has_calls(expected_calls) self.assertEqual(1, mock_socket.call_count)