Commit 5dd46726 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Remove a test using mocket

'mocket' doesn't support Unix sockets and at some point a release seems
to have broken the test.
parent ace81cef
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -40,7 +40,6 @@ include =
test =
  anyio[curio]
  coverage <5
  mocket[speedups]
  nose2[coverage_plugin]

[unittest]

tests/unit/test_util.py

deleted100644 → 0
+0 −57
Original line number Diff line number Diff line
#  Copyright 2019  Dom Sekotill <dom.sekotill@kodo.org.uk>
#
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

"""
Test cases for wpa_supplicant.util functions
"""

import socket
import unittest
import warnings
from unittest.mock import patch

import anyio
from mocket import Mocket
from mocket import MocketEntry
from mocket import mocketize
from wpa_supplicant import util


class AnyIOTests(unittest.TestCase):
	"""
	Tests for 'anyio' functions in util
	"""

	@mocketize
	@patch("mocket.mocket.MocketSocket.getsockopt", return_value=0)
	@patch("mocket.mocket.MocketSocket.connect")
	def test_connect_unix_datagram(self, mock_connect, mock_getsockopt):
		"""
		Check that a socket of the right type is wrapped, bound and connected after a call
		"""
		test_path = "/some/path"
		Mocket.register(MocketEntry(test_path, []))

		# Perform the action
		sock = anyio.run(util.connect_unix_datagram, test_path)

		# This will pick up changes that may need to be made to the test mocks
		if mock_getsockopt.call_count != 1:
			warnings.warn("getsockopt() call count != 1")

		# The socket MUST be a UNIX DATAGRAM type
		self.assertEqual(sock.family, socket.AF_UNIX)
		self.assertEqual(sock.type, socket.SOCK_DGRAM)

		mock_connect.assert_called_once_with(test_path)