Skip to content

Commit

Permalink
cryomech agent: Test init task
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJKoopman committed Jun 8, 2022
1 parent 72c24b9 commit 7396253
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,13 @@ hosts:
['--mode', 'init'],
]
},
{'agent-class': 'CryomechCPAAgent',
'instance-id': 'cryomech',
'arguments':[['--ip-address', '127.0.0.1'],
['--serial-number', 'CPA1234TEST-111111A'],
['--mode', 'init'],
['--port', 5502],
]
},
]
}
59 changes: 59 additions & 0 deletions tests/integration/test_cryomech_cpa_agent_integration.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import os
import pytest

import ocs
from ocs.base import OpCode

from ocs.testing import (
create_agent_runner_fixture,
create_client_fixture,
)

from integration.util import (
create_crossbar_fixture
)

from socs.testing.device_emulator import create_device_emulator

pytest_plugins = ("docker_compose")

# Set the OCS_CONFIG_DIR so we read the local default.yaml file always
os.environ['OCS_CONFIG_DIR'] = os.getcwd()

# Raw bytes message/response for Agent init
init_msg = b'\t\x99\x00\x00\x00\x06\x01\x04\x00\x01\x005'
init_res = b'\t\x99\x00\x00\x00m\x01\x04j\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x80\x00A\x06B\x83\xfcjB\x82k\x85B\x84\xe6fB\x85.\xb8C[\t\x0cC[\xf1\x82CZ6\xeeC[\xd8\x00\xbetwG>`\xd6\x00F%\x00\x00\x00\x00)<\x04\x18\x02\x9a\x04u\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'

wait_for_crossbar = create_crossbar_fixture()
run_agent = create_agent_runner_fixture(
'../agents/cryomech_cpa/cryomech_cpa_agent.py', 'cryomech_cpa_agent')
client = create_client_fixture('cryomech')
emulator = create_device_emulator({init_msg: init_res}, relay_type='tcp', port=5502, encoding=None)


@pytest.mark.integtest
def test_cryomech_cpa_init(wait_for_crossbar, emulator, run_agent,
client):
resp = client.init.wait()
resp = client.init.status()
print(resp)
assert resp.status == ocs.OK
print(resp.session)
assert resp.session['op_code'] == OpCode.SUCCEEDED.value


# @pytest.mark.integtest
# def test_pfeiffer_tc400_turn_turbo_on(wait_for_crossbar, emulator, run_agent,
# client):
# client.init()
#
# responses = {'0011001006111111015': format_reply('111111'), # ready_turbo()
# '0011002306111111019': format_reply('111111'), # turn_turbo_motor_on()
# }
# emulator.define_responses(responses)
#
# resp = client.turn_turbo_on()
# print(resp)
# assert resp.status == ocs.OK
# print(resp.session)
# assert resp.session['op_code'] == OpCode.SUCCEEDED.value

0 comments on commit 7396253

Please sign in to comment.