[route][config] fix GET /mac
This commit is contained in:
parent
34a2f0c49d
commit
e895baedbc
2 changed files with 17 additions and 5 deletions
|
|
@ -57,10 +57,6 @@ def save_config():
|
|||
config.write(conf_file)
|
||||
|
||||
|
||||
def get_mac():
|
||||
return get_config_dict()['heatpump', 'mac_address']
|
||||
|
||||
|
||||
def mac_address_init():
|
||||
from netifaces import gateways, ifaddresses, AF_INET, AF_LINK
|
||||
|
||||
|
|
@ -112,6 +108,10 @@ async def config_route(request, *args, **kwargs):
|
|||
return await set_config(request)
|
||||
|
||||
|
||||
def get_mac():
|
||||
return config.get('heatpump','mac_address')
|
||||
|
||||
|
||||
async def mac_route(request, *args, **kwargs):
|
||||
if request['method'] == 'GET':
|
||||
return PlainTextResponse(get_mac())
|
||||
|
|
|
|||
|
|
@ -81,12 +81,24 @@ def test_set_config(tmpconf):
|
|||
|
||||
|
||||
def test_mac_address(testdir, tmpconf):
|
||||
c = TestClient(app)
|
||||
_, tmpconf = mkstemp()
|
||||
CONFIG_FILES.append(tmpconf)
|
||||
|
||||
mac_address = mac_address_init()
|
||||
assert type(get_config_dict()) == dict
|
||||
d_config =get_config_dict()
|
||||
d_config = get_config_dict()
|
||||
|
||||
assert d_config['heatpump']['mac_address'] == mac_address
|
||||
|
||||
resp = c.get('/mac')
|
||||
assert resp.status_code == 200
|
||||
mac_address = resp.content.decode()
|
||||
|
||||
assert d_config['heatpump']['mac_address'] == mac_address
|
||||
|
||||
|
||||
|
||||
|
||||
def test_last_update(testdir, tmpconf):
|
||||
c = TestClient(app)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue