Beispiel #1
0
import sys
sys.path.insert(0, '../agents/hwp_rotation/')
from src.pid_controller import PID

from socs.testing.device_emulator import create_device_emulator

pid_emu = create_device_emulator({'*W02400000': 'W02\r'},
                                 relay_type='tcp',
                                 port=3003)


def test_send_message(pid_emu):
    pid = PID('127.0.0.1', 3003)
    responses = {'ping': 'pong'}
    pid_emu.define_responses(responses)
    resp = pid.send_message('ping')
    assert resp == 'pong'


def test_get_direction(pid_emu):
    pid = PID('127.0.0.1', 3003)
    responses = {'*R02': 'R02400000\r'}
    pid_emu.define_responses(responses)
    pid.get_direction()


def test_set_direction(pid_emu):
    pid = PID('127.0.0.1', 3003)
    responses = {"*W02400000": 'W02\r'}
    pid_emu.define_responses(responses)
    pid.set_direction('0')
Beispiel #2
0
import time
import pytest

from socs.agent.pmx import Command, PMX
from socs.testing.device_emulator import create_device_emulator


tcp_emulator = create_device_emulator({'ping': 'pong\r',
                                       'SYST:REM': 'test'},
                                      'tcp', 9001)


# Tried this as a fixture, but connections weren't cleaning up properly.
def create_command():
    # Connection might not work on first attempt
    for i in range(5):
        try:
            pmx = PMX(tcp_ip='127.0.0.1', tcp_port=9001, timeout=0.1)
            cmd = Command(pmx)
            break
        except ConnectionRefusedError:
            print("Could not connect, waiting and trying again.")
            time.sleep(1)
    return cmd


@pytest.mark.integtest
def test_pmx_create_command(tcp_emulator):
    create_command()

Beispiel #3
0
def test_create_device_emulator_invalid_type():
    with pytest.raises(NotImplementedError):
        device_emulator.create_device_emulator({}, relay_type='test')
Beispiel #4
0
import time
import pytest

from socs.agent import moxaSerial
from socs.testing.device_emulator import create_device_emulator

tcp_emulator = create_device_emulator({'ping': 'pong\r'}, 'tcp', 9001)


# Tried this as a fixture, but connections weren't cleaning up properly.
def create_tcpserver():
    # Connection might not work on first attempt
    for i in range(5):
        try:
            ser = moxaSerial.Serial_TCPServer(('127.0.0.1', 9001), 0.1)
            break
        except ConnectionRefusedError:
            print("Could not connect, waiting and trying again.")
            time.sleep(1)
    return ser


@pytest.mark.integtest
def test_moxaserial_create_serial_tcpserver(tcp_emulator):
    create_tcpserver()


@pytest.mark.integtest
def test_moxaserial_write(tcp_emulator):
    ser = create_tcpserver()
    ser.write('ping')
Beispiel #5
0
        'HTR?': '+00.0005E+00'
    })

    # Senor readings
    values.update({
        'KRDG? 1': '+293.873E+00',
        'SRDG? 1': '+108.278E+00',
        'KRDG? A': '+00.0000E-03',
        'SRDG? A': '+000.000E+09'
    })

    return values


emulator = create_device_emulator(build_init_responses(),
                                  relay_type='tcp',
                                  port=7777)


@pytest.mark.integtest
def test_testing(wait_for_crossbar):
    """Just a quick test to make sure we can bring up crossbar."""
    assert True


@pytest.mark.integtest
def test_ls372_init_lakeshore(wait_for_crossbar, emulator, run_agent, client):
    resp = client.init_lakeshore()
    # print(resp)
    assert resp.status == ocs.OK
    # print(resp.session)
    'INTYPE? 2': '1,1,0,0,1,1',
    'INNAME? 2': 'Channel 2',
    'INTYPE? 3': '1,1,0,0,1,1',
    'INNAME? 3': 'Channel 3',
    'INTYPE? 4': '1,1,0,0,1,1',
    'INNAME? 4': 'Channel 4',
    'INTYPE? 5': '1,1,0,0,1,1',
    'INNAME? 5': 'Channel 5',
    'INTYPE? 6': '1,1,0,0,1,1',
    'INNAME? 6': 'Channel 6',
    'INTYPE? 7': '1,1,0,0,1,1',
    'INNAME? 7': 'Channel 7',
    'INTYPE? 8': '1,1,0,0,1,1',
    'INNAME? 8': 'Channel 8'
}
emulator = create_device_emulator(initial_responses, relay_type='serial')


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


@pytest.mark.integtest
def test_ls240_start_acq(wait_for_crossbar, emulator, run_agent, client):
    client.init_lakeshore()
from socs.testing.device_emulator import create_device_emulator

pytest_plugins = ("docker_compose")

wait_for_crossbar = create_crossbar_fixture()
run_agent = create_agent_runner_fixture(
    '../agents/hwp_rotation/rotation_agent.py',
    'hwp_rotation_agent',
    args=['--log-dir', './logs/'])
run_agent_idle = create_agent_runner_fixture(
    '../agents/hwp_rotation/rotation_agent.py',
    'hwp_rotation_agent',
    args=['--mode', 'idle', '--log-dir', './logs/'])
client = create_client_fixture('rotator')
kikusui_emu = create_device_emulator({'SYST:REM': ''},
                                     relay_type='tcp',
                                     port=2000)
pid_emu = create_device_emulator({'*W02400000': 'W02\r'},
                                 relay_type='tcp',
                                 port=2001)


@pytest.mark.integtest
def test_testing(wait_for_crossbar):
    """Just a quick test to make sure we can bring up crossbar."""
    assert True


# This ends up hanging for some reason that I can't figure out at the moment.
# @pytest.mark.integtest
# def test_hwp_rotation_failed_connection_kikusui(wait_for_crossbar, pid_emu, run_agent_idle, client):
Beispiel #8
0
    Parameters:
        data (str): Data string to package into telegram.

    Returns:
        str: The full telegram string that is emulating the response from the
            TC400.

    """
    return chksum_msg('001' + '10' + '010' + '{:02d}'.format(len(data)) + data)


wait_for_crossbar = create_crossbar_fixture()
run_agent = create_agent_runner_fixture(
    '../agents/pfeiffer_tc400/pfeiffer_tc400_agent.py', 'tc400_agent')
client = create_client_fixture('pfeifferturboA')
emulator = create_device_emulator({}, relay_type='tcp')


@pytest.mark.integtest
def test_pfeiffer_tc400_init_lakeshore(wait_for_crossbar, emulator, run_agent,
                                       client):
    resp = client.init()
    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):
Beispiel #9
0
from integration.util import (
    create_crossbar_fixture
)

from socs.testing.device_emulator import create_device_emulator

pytest_plugins = ("docker_compose")

wait_for_crossbar = create_crossbar_fixture()
run_agent = create_agent_runner_fixture(
    '../agents/lakeshore425/LS425_agent.py', 'ls425_agent')
run_agent_acq = create_agent_runner_fixture(
    '../agents/lakeshore425/LS425_agent.py', 'ls425_agent', args=['--mode', 'acq'])
client = create_client_fixture('LS425')
emulator = create_device_emulator({'*IDN?': 'LSCI,MODEL425,LSA425T,1.3'},
                                  relay_type='serial')


@pytest.mark.integtest
def test_testing(wait_for_crossbar):
    """Just a quick test to make sure we can bring up crossbar."""
    assert True


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