Commit 21c55db7 authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Rename MasterClient to GlobalClient

GlobalClient more accurately matches the wpa_supplicant documentation's
description of the socket it connects to (the 'global' socket).
parent 2baae075
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ from unittest import TestCase

from tests._anyio import with_anyio
from tests.integration.util import start_server
from wpa_supplicant.client import master
from wpa_supplicant.client import GlobalClient


class Tests(TestCase):
@@ -37,7 +37,7 @@ class Tests(TestCase):
		"""
		Test connecting to the global wpa_supplicant control socket
		"""
		async with start_server() as sock, master.MasterClient() as client:
		async with start_server() as sock, GlobalClient() as client:
			await client.connect(sock)
			ifaces = await client.list_interfaces()
			assert len(ifaces) == 0
@@ -51,7 +51,7 @@ class Tests(TestCase):
		"""
		if os.getuid() != 0:
			self.skipTest("test_new_interface requires root privileges")
		async with start_server() as sock, master.MasterClient() as mclient:
		async with start_server() as sock, GlobalClient() as mclient:
			await mclient.connect(sock)
			async with await mclient.connect_interface('wlan0') as iclient:
				async for iface in iclient.scan():
+9 −9
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@
#  limitations under the License.

"""
Test cases for wpa_supplicant.client.master.MasterClient
Test cases for wpa_supplicant.client.GlobalClient
"""

import pathlib
@@ -21,8 +21,8 @@ import unittest
from unittest.mock import patch

from tests import _anyio as anyio_mock
from wpa_supplicant.client import interfaces
from wpa_supplicant.client import master
from wpa_supplicant.client import GlobalClient
from wpa_supplicant.client import InterfaceClient


class InterfaceMethodsTests(unittest.TestCase):
@@ -31,7 +31,7 @@ class InterfaceMethodsTests(unittest.TestCase):
	"""

	def setUp(self):
		self.client = client = master.MasterClient()
		self.client = client = GlobalClient()
		client.sock = anyio_mock.AsyncMock()
		client.sock.send.return_value = None

@@ -40,8 +40,8 @@ class InterfaceMethodsTests(unittest.TestCase):
		"""
		Check that connect sets ctrl_dir
		"""
		client1 = master.MasterClient()
		client2 = master.MasterClient()
		client1 = GlobalClient()
		client2 = GlobalClient()

		with patch(
			"wpa_supplicant.client.base.BaseClient.connect",
@@ -108,7 +108,7 @@ class InterfaceMethodsTests(unittest.TestCase):

			ifclient = await client.connect_interface("enp1s0")

			self.assertIsInstance(ifclient, interfaces.InterfaceClient)
			self.assertIsInstance(ifclient, InterfaceClient)
			connect_mock.assert_called_once_with(pathlib.Path("/tmp/enp1s0"))

			# Check only INTERFACES was sent
@@ -132,7 +132,7 @@ class InterfaceMethodsTests(unittest.TestCase):

			ifclient = await client.connect_interface("enp1s0")

			self.assertIsInstance(ifclient, interfaces.InterfaceClient)
			self.assertIsInstance(ifclient, InterfaceClient)
			connect_mock.assert_called_once_with(pathlib.Path("/tmp/enp1s0"))

			# Check INTERFACE_ADD sent after INTERFACES
@@ -148,7 +148,7 @@ class InterfaceMethodsTests(unittest.TestCase):
		This is similar to the identically-named test on the base class, but checks there
		are no issues related to the socket directory not being set.
		"""
		client = master.MasterClient()
		client = GlobalClient()

		with self.assertRaises(RuntimeError):
			await client.add_interface("interface")
+2 −2
Original line number Diff line number Diff line
@@ -16,14 +16,14 @@
WPA-Supplicant client classes
"""

from ._global import GlobalClient
from .base import BaseClient
from .consts import *
from .consts import __all__ as _consts_names
from .interfaces import InterfaceClient
from .master import MasterClient

__all__ = _consts_names + (
	'BaseClient',
	'MasterClient',
	'GlobalClient',
	'InterfaceClient',
)
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ from .base import BaseClient
from .interfaces import InterfaceClient


class MasterClient(BaseClient):
class GlobalClient(BaseClient):
	"""
	A client for listing, adding and removing interfaces, and getting per-client interfaces
	"""
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ class BaseClient:
	"""
	A client for controlling a WPA-Supplicant daemon over a control socket

	This class is a naïve implementation. You probably want MasterClient and
	This class is a naïve implementation. You probably want GlobalClient and
	InterfaceClient.
	"""