blob: 128393942040c43b5c7b4dcefd770783f11e96c2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
import asyncio
import os
import pytest
import logging
from pyagl.services.base import AFBResponse, AFBT
from pyagl.services.can import CANService as cs
pytestmark = [pytest.mark.asyncio, pytest.mark.can]
@pytest.fixture(scope='module')
def event_loop():
loop = asyncio.get_event_loop()
yield loop
@pytest.fixture(scope='module')
async def service():
address = os.environ.get('AGL_TGT_IP', 'localhost')
port = os.environ.get('AGL_TGT_PORT', None)
svc = await cs(ip=address, port=port)
yield svc
await svc.websocket.close()
@pytest.mark.regular
async def test_list(event_loop, service: cs):
msgid = await service.list()
resp = await service.afbresponse()
assert resp.status == 'success'
@pytest.mark.regular
async def test_get(event_loop, service: cs):
msgid = await service.get("engine.speed")
resp = await service.afbresponse()
assert resp.status == 'success'
@pytest.mark.regular
async def test_auth(event_loop, service: cs):
msgid = await service.auth()
resp = await service.afbresponse()
assert resp.status == 'success'
@pytest.mark.regular
async def test_write(event_loop, service: cs):
msgid = await service.write({"signal_name": "hvac.temperature.left", "signal_value": 21})
resp = await service.afbresponse()
assert resp.status == 'success'
|