Skip to content

Commit

Permalink
Bump version 1.17 and fix linting
Browse files Browse the repository at this point in the history
  • Loading branch information
mrchi committed Mar 4, 2024
1 parent 48747d2 commit c872abd
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 66 deletions.
35 changes: 21 additions & 14 deletions openwrt_luci_rpc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,26 @@
"""Top-level package for openwrt-luci-rpc."""

__author__ = """Finbarr Brady"""
__email__ = 'fbradyirl@github.io'
__version__ = '1.1.16'
__email__ = "fbradyirl@github.io"
__version__ = "1.1.17"

from .openwrt_luci_rpc import OpenWrtLuciRPC
from .constants import Constants
from .openwrt_luci_rpc import OpenWrtLuciRPC


class OpenWrtRpc:
"""
Class to interact with OpenWrt router running luci-mod-rpc package.
"""

def __init__(self, host_url=Constants.DEFAULT_LOCAL_HOST,
username=Constants.DEFAULT_USERNAME,
password=Constants.DEFAULT_PASSWORD,
is_https=Constants.DEFAULT_HTTPS,
verify_https=Constants.DEFAULT_VERIFY_HTTPS):
def __init__(
self,
host_url=Constants.DEFAULT_LOCAL_HOST,
username=Constants.DEFAULT_USERNAME,
password=Constants.DEFAULT_PASSWORD,
is_https=Constants.DEFAULT_HTTPS,
verify_https=Constants.DEFAULT_VERIFY_HTTPS,
):
"""
Initiate an instance with a default local ip (192.168.1.1)
:param host_url: string - host url. Defaults to 192.168.1.1
Expand All @@ -28,16 +31,20 @@ def __init__(self, host_url=Constants.DEFAULT_LOCAL_HOST,
:param is_https: boolean - use https? Default is false
:param verify_https: boolean - verify https? Default is true
"""
self.router = OpenWrtLuciRPC(host_url, username, password,
is_https, verify_https)
self.router = OpenWrtLuciRPC(
host_url, username, password, is_https, verify_https
)

def is_logged_in(self):
"""Returns true if a token has been aquired"""
return self.router.token is not None

def get_all_connected_devices(self,
only_reachable=Constants.DEFAULT_ONLY_REACH,
wlan_interfaces=Constants.DEFAULT_WLAN_IF):
def get_all_connected_devices(
self,
only_reachable=Constants.DEFAULT_ONLY_REACH,
wlan_interfaces=Constants.DEFAULT_WLAN_IF,
):
"""Get details of all devices"""
return self.router.get_all_connected_devices(
only_reachable=only_reachable, wlan_interfaces=wlan_interfaces)
only_reachable=only_reachable, wlan_interfaces=wlan_interfaces
)
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.16
current_version = 1.1.17
commit = True
tag = True

Expand Down
38 changes: 19 additions & 19 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,42 +3,42 @@

"""The setup script."""

from setuptools import setup, find_packages
from setuptools import find_packages, setup

with open('README.rst') as readme_file:
with open("README.rst") as readme_file:
readme = readme_file.read()

with open('HISTORY.rst') as history_file:
with open("HISTORY.rst") as history_file:
history = history_file.read()

requirements = ['Click>=6.0', 'requests>=2.21.0', 'packaging>=19.1']
requirements = ["Click>=6.0", "requests>=2.21.0", "packaging>=19.1"]

setup_requirements = [ ]
setup_requirements = []

test_requirements = [ ]
test_requirements = []

setup(
author="Finbarr Brady",
author_email='fbradyirl@github.io',
author_email="fbradyirl@github.io",
classifiers=[
'Development Status :: 2 - Pre-Alpha',
'Intended Audience :: Developers',
'License :: OSI Approved :: Apache Software License',
'Natural Language :: English',
'Programming Language :: Python :: 3.7',
"Development Status :: 2 - Pre-Alpha",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Natural Language :: English",
"Programming Language :: Python :: 3.7",
],
description="Module for interacting with OpenWrt Luci RPC interface",
install_requires=requirements,
license="Apache Software License 2.0",
long_description=readme + '\n\n' + history,
long_description=readme + "\n\n" + history,
include_package_data=True,
keywords='openwrt-luci-rpc',
name='openwrt-luci-rpc',
packages=find_packages(include=['openwrt_luci_rpc']),
keywords="openwrt-luci-rpc",
name="openwrt-luci-rpc",
packages=find_packages(include=["openwrt_luci_rpc"]),
setup_requires=setup_requirements,
test_suite='tests',
test_suite="tests",
tests_require=test_requirements,
url='https://github.com/fbradyirl/openwrt-luci-rpc',
version='1.1.16',
url="https://github.com/fbradyirl/openwrt-luci-rpc",
version="1.1.17",
zip_safe=False,
)
70 changes: 38 additions & 32 deletions tests/test_openwrt_60.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,50 +21,56 @@ def tearDown(self):
def test_get_hostname_from_dhcp_mac_list_formating(self):
"""Test if lower case list of MAC match with Upper case."""

data = [{
".name": "cfg07ee1",
".type": "host",
"name": "imac-ethernet",
".index": 4,
"mac": ["c8:2a:10:4a:10:dd"],
"dns": "1",
".anonymous": True,
"ip": "192.168.1.124"
}]
data = [
{
".name": "cfg07ee1",
".type": "host",
"name": "imac-ethernet",
".index": 4,
"mac": ["c8:2a:10:4a:10:dd"],
"dns": "1",
".anonymous": True,
"ip": "192.168.1.124",
}
]

data = utilities.get_hostname_from_dhcp(data, "C8:2A:10:4A:10:DD")
assert data is None

def test_get_hostname_from_dhcp_mac_string_formating(self):
"""Test if lower case string of MAC match with Upper case."""

data = [{
".name": "cfg07ee1",
".type": "host",
"name": "imac-ethernet",
".index": 4,
"mac": "c8:2a:10:4a:10:dd",
"dns": "1",
".anonymous": True,
"ip": "192.168.1.124"
}]
data = [
{
".name": "cfg07ee1",
".type": "host",
"name": "imac-ethernet",
".index": 4,
"mac": "c8:2a:10:4a:10:dd",
"dns": "1",
".anonymous": True,
"ip": "192.168.1.124",
}
]

data = utilities.get_hostname_from_dhcp(data, "C8:2A:10:4A:10:DD")
assert data is None

def test_get_hostname_from_dhcp_multiple_mac_string_formating(self):
"""Test if lower case string of MAC match with Upper case of multi mac list."""

data = [{
".name": "cfg07ee1",
".type": "host",
"name": "imac-ethernet",
".index": 4,
"mac": {"c8:2a:10:4a:10:d9","c8:2a:10:4a:10:dd"},
"dns": "1",
".anonymous": True,
"ip": "192.168.1.124"
}]
"""Test if lower case string of MAC match with Upper case of multi mac list.""" # noqa: E501python setup.py test

data = [
{
".name": "cfg07ee1",
".type": "host",
"name": "imac-ethernet",
".index": 4,
"mac": {"c8:2a:10:4a:10:d9", "c8:2a:10:4a:10:dd"},
"dns": "1",
".anonymous": True,
"ip": "192.168.1.124",
}
]

data = utilities.get_hostname_from_dhcp(data, "C8:2A:10:4A:10:DD")
assert data is None
Expand Down

0 comments on commit c872abd

Please sign in to comment.