Commit a81da17e authored by Matias Guijarro's avatar Matias Guijarro
Browse files

tests: first attempt to add tests for wago controller

parent d9f6168a
plugin: bliss
class: wago
name: wcid00
controller_ip: localhost
mapping:
-
type: 750-530
logical_names: attctrl,_,attctrl,_,attctrl,_,attctrl,_
-
type: 750-530
logical_names: attctrl,detcover_ctrl,attctrl,_,attctrl, _,attctrl,_
-
type: 750-436
logical_names: attstatus,attstatus,attstatus,attstatus,attstatus,attstatus,attstatus,attstatus
# -*- coding: utf-8 -*-
#
# This file is part of the bliss project
#
# Copyright (c) 2016 Beamline Control Unit, ESRF
# Distributed under the GNU LGPLv3. See LICENSE for more info.
import pytest
import time
import mock
import inspect
def read_coils(what, size):
print "read coils", what, size
cc = inspect.currentframe().f_back
print "modules to read", cc.f_locals["modules_to_read"]
print "mapping", cc.f_locals["self"].mapping
if what == 512:
# IN
return [0]*size
else:
# OUT
return [1]*size
def write_coil(*args, **kwargs):
print "write coil", args, kwargs
def read_input_registers(*args, **kwargs):
print "read input registers", args, kwargs
def write_register(*args, **kwargs):
print "write register", args, kwargs
def test_wago(beacon):
w = beacon.get("wcid00")
w.connect()
with mock.patch.object(w.controller.client, "read_coils", read_coils):
with mock.patch.object(w.controller.client, "read_input_registers", read_input_registers):
with mock.patch.object(w.controller.client, "write_coil", write_coil):
with mock.patch.object(w.controller.client, "write_register", write_register):
print w.get("attctrl", "attstatus")
#w.set("attctrl", *[1]*8)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment