mirror of
https://github.com/naruxde/revpimodio2.git
synced 2025-11-08 13:53:53 +01:00
test: Add RevPi Compact tests
This commit is contained in:
1
tests/compact/config_compact.rsc
Normal file
1
tests/compact/config_compact.rsc
Normal file
@@ -0,0 +1 @@
|
||||
{"App":{"name": "PiCtory", "version": "1.4.3","saveTS": "20200428181820","language": "en","layout": {"north":{"size":70,"initClosed":false,"initHidden":false},"south":{"size":420,"initClosed":false,"initHidden":false,"children":{"layout1":{"east":{"size":500,"initClosed":false,"initHidden":false}}}},"east":{"size":0,"initClosed":true,"initHidden":false,"children":{}},"west":{"size":200,"initClosed":false,"initHidden":false,"children":{"layout1":{}}}}},"Summary":{"inpTotal": 23,"outTotal": 6},"Devices":[{"GUID": "d22a4b56-7646-ab9b-b205-52a738abf5e0","id": "device_RevPiCompact_20171023_1_0_001","type": "BASE","productType": "104","position": "0","name": "RevPi Compact","bmk": "RevPi Compact","inpVariant": 0,"outVariant": 0,"comment": "This is a RevPiCompact Device","offset": 0,"inp": {"0": ["Core_Temperature","0","8","0",false,"0000", "",""],"1": ["Core_Frequency","0","8","1",false,"0001", "",""],"2": ["DIn_i01","0","8","2",true,"0002", "",""],"3": ["AIn_1","0","16","3",false,"0003", "",""],"4": ["AIn_2","0","16","5",false,"0004", "",""],"5": ["AIn_3","0","16","7",false,"0005", "",""],"6": ["AIn_4","0","16","9",false,"0006", "",""],"7": ["AIn_5","0","16","11",false,"0007", "",""],"8": ["AIn_6","0","16","13",false,"0008", "",""],"9": ["AIn_7","0","16","15",false,"0009", "",""],"10": ["AIn_8","0","16","17",false,"0010", "",""],"11": ["DIn_Status","0","8","19",false,"0011", "",""],"12": ["DOut_Status","0","8","20",false,"0012", "",""],"13": ["AIn_Status","0","8","21",false,"0013", "",""],"14": ["AOut_Status","0","8","22",false,"0014", "",""]},"out": {"0": ["RevPiLED","0","8","23",true,"0015", "",""],"1": ["DOut","0","8","24",false,"0016", "",""],"2": ["AOut_1","0","16","25",false,"0017", "",""],"3": ["AOut_2","0","16","27",false,"0018", "",""]},"mem": {"0": ["InputDebounce","0","8","29",false,"0019", "",""],"1": ["AInMode_1","0","8","30",false,"0020", "Select the type of input signal",""],"2": ["AInMode_2","0","8","31",false,"0021", "Select the type of input signal",""],"3": ["AInMode_3","0","8","32",false,"0022", "Select the type of input signal",""],"4": ["AInMode_4","0","8","33",false,"0023", "Select the type of input signal",""],"5": ["AInMode_5","0","8","34",false,"0024", "Select the type of input signal",""],"6": ["AInMode_6","0","8","35",false,"0025", "Select the type of input signal",""],"7": ["AInMode_7","0","8","36",false,"0026", "Select the type of input signal",""],"8": ["AInMode_8","0","8","37",false,"0027", "Select the type of input signal",""]},"extend": {}}],"Connections":[]}
|
||||
420
tests/compact/config_compact_bits.json
Normal file
420
tests/compact/config_compact_bits.json
Normal file
@@ -0,0 +1,420 @@
|
||||
{
|
||||
"App": {
|
||||
"name": "PiCtory",
|
||||
"version": "1.4.3",
|
||||
"saveTS": "20200428181820",
|
||||
"language": "en",
|
||||
"layout": {
|
||||
"north": {
|
||||
"size": 70,
|
||||
"initClosed": false,
|
||||
"initHidden": false
|
||||
},
|
||||
"south": {
|
||||
"size": 420,
|
||||
"initClosed": false,
|
||||
"initHidden": false,
|
||||
"children": {
|
||||
"layout1": {
|
||||
"east": {
|
||||
"size": 500,
|
||||
"initClosed": false,
|
||||
"initHidden": false
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"east": {
|
||||
"size": 0,
|
||||
"initClosed": true,
|
||||
"initHidden": false,
|
||||
"children": {}
|
||||
},
|
||||
"west": {
|
||||
"size": 200,
|
||||
"initClosed": false,
|
||||
"initHidden": false,
|
||||
"children": {
|
||||
"layout1": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"Summary": {
|
||||
"inpTotal": 23,
|
||||
"outTotal": 6
|
||||
},
|
||||
"Devices": [
|
||||
{
|
||||
"GUID": "d22a4b56-7646-ab9b-b205-52a738abf5e0",
|
||||
"id": "device_RevPiCompact_20171023_1_0_001",
|
||||
"type": "BASE",
|
||||
"productType": "104",
|
||||
"position": "0",
|
||||
"name": "RevPi Compact",
|
||||
"bmk": "RevPi Compact",
|
||||
"inpVariant": 0,
|
||||
"outVariant": 0,
|
||||
"comment": "This is a RevPiCompact Device",
|
||||
"offset": 0,
|
||||
"inp": {
|
||||
"0": [
|
||||
"Core_Temperature",
|
||||
"0",
|
||||
"8",
|
||||
"0",
|
||||
false,
|
||||
"0000",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"1": [
|
||||
"Core_Frequency",
|
||||
"0",
|
||||
"8",
|
||||
"1",
|
||||
false,
|
||||
"0001",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"2": [
|
||||
"DIn_i01",
|
||||
"0",
|
||||
"8",
|
||||
"2",
|
||||
true,
|
||||
"0002",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"3": [
|
||||
"AIn_1",
|
||||
"0",
|
||||
"16",
|
||||
"3",
|
||||
false,
|
||||
"0003",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"4": [
|
||||
"AIn_2",
|
||||
"0",
|
||||
"16",
|
||||
"5",
|
||||
false,
|
||||
"0004",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"5": [
|
||||
"AIn_3",
|
||||
"0",
|
||||
"16",
|
||||
"7",
|
||||
false,
|
||||
"0005",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"6": [
|
||||
"AIn_4",
|
||||
"0",
|
||||
"16",
|
||||
"9",
|
||||
false,
|
||||
"0006",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"7": [
|
||||
"AIn_5",
|
||||
"0",
|
||||
"16",
|
||||
"11",
|
||||
false,
|
||||
"0007",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"8": [
|
||||
"AIn_6",
|
||||
"0",
|
||||
"16",
|
||||
"13",
|
||||
false,
|
||||
"0008",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"9": [
|
||||
"AIn_7",
|
||||
"0",
|
||||
"16",
|
||||
"15",
|
||||
false,
|
||||
"0009",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"10": [
|
||||
"AIn_8",
|
||||
"0",
|
||||
"16",
|
||||
"17",
|
||||
false,
|
||||
"0010",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"11": [
|
||||
"DIn_Status",
|
||||
"0",
|
||||
"8",
|
||||
"19",
|
||||
false,
|
||||
"0011",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"12": [
|
||||
"DOut_Status",
|
||||
"0",
|
||||
"8",
|
||||
"20",
|
||||
false,
|
||||
"0012",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"13": [
|
||||
"AIn_Status",
|
||||
"0",
|
||||
"8",
|
||||
"21",
|
||||
false,
|
||||
"0013",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"14": [
|
||||
"AOut_Status",
|
||||
"0",
|
||||
"8",
|
||||
"22",
|
||||
false,
|
||||
"0014",
|
||||
"",
|
||||
""
|
||||
]
|
||||
},
|
||||
"out": {
|
||||
"0": [
|
||||
"a1green",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0012",
|
||||
"",
|
||||
"0"
|
||||
],
|
||||
"1": [
|
||||
"a1red",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0013",
|
||||
"",
|
||||
"1"
|
||||
],
|
||||
"2": [
|
||||
"a2green",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0014",
|
||||
"",
|
||||
"2"
|
||||
],
|
||||
"3": [
|
||||
"a2red",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0015",
|
||||
"",
|
||||
"3"
|
||||
],
|
||||
"4": [
|
||||
"a3green",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0016",
|
||||
"",
|
||||
"4"
|
||||
],
|
||||
"5": [
|
||||
"a3red",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0017",
|
||||
"",
|
||||
"5"
|
||||
],
|
||||
"6": [
|
||||
"x2out",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0018",
|
||||
"",
|
||||
"6"
|
||||
],
|
||||
"7": [
|
||||
"wd",
|
||||
"0",
|
||||
"1",
|
||||
"23",
|
||||
true,
|
||||
"0019",
|
||||
"",
|
||||
"7"
|
||||
],
|
||||
"8": [
|
||||
"DOut",
|
||||
"0",
|
||||
"8",
|
||||
"24",
|
||||
false,
|
||||
"0016",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"9": [
|
||||
"AOut_1",
|
||||
"0",
|
||||
"16",
|
||||
"25",
|
||||
false,
|
||||
"0017",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"10": [
|
||||
"AOut_2",
|
||||
"0",
|
||||
"16",
|
||||
"27",
|
||||
false,
|
||||
"0018",
|
||||
"",
|
||||
""
|
||||
]
|
||||
},
|
||||
"mem": {
|
||||
"0": [
|
||||
"InputDebounce",
|
||||
"0",
|
||||
"8",
|
||||
"29",
|
||||
false,
|
||||
"0019",
|
||||
"",
|
||||
""
|
||||
],
|
||||
"1": [
|
||||
"AInMode_1",
|
||||
"0",
|
||||
"8",
|
||||
"30",
|
||||
false,
|
||||
"0020",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"2": [
|
||||
"AInMode_2",
|
||||
"0",
|
||||
"8",
|
||||
"31",
|
||||
false,
|
||||
"0021",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"3": [
|
||||
"AInMode_3",
|
||||
"0",
|
||||
"8",
|
||||
"32",
|
||||
false,
|
||||
"0022",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"4": [
|
||||
"AInMode_4",
|
||||
"0",
|
||||
"8",
|
||||
"33",
|
||||
false,
|
||||
"0023",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"5": [
|
||||
"AInMode_5",
|
||||
"0",
|
||||
"8",
|
||||
"34",
|
||||
false,
|
||||
"0024",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"6": [
|
||||
"AInMode_6",
|
||||
"0",
|
||||
"8",
|
||||
"35",
|
||||
false,
|
||||
"0025",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"7": [
|
||||
"AInMode_7",
|
||||
"0",
|
||||
"8",
|
||||
"36",
|
||||
false,
|
||||
"0026",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
],
|
||||
"8": [
|
||||
"AInMode_8",
|
||||
"0",
|
||||
"8",
|
||||
"37",
|
||||
false,
|
||||
"0027",
|
||||
"Select the type of input signal",
|
||||
""
|
||||
]
|
||||
},
|
||||
"extend": {}
|
||||
}
|
||||
],
|
||||
"Connections": []
|
||||
}
|
||||
61
tests/compact/test_compact.py
Normal file
61
tests/compact/test_compact.py
Normal file
@@ -0,0 +1,61 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
"""Test for RevPi Compact."""
|
||||
__author__ = "Sven Sager"
|
||||
__copyright__ = "Copyright (C) 2024 Sven Sager"
|
||||
__license__ = "GPLv2"
|
||||
|
||||
from os.path import join, dirname
|
||||
|
||||
import revpimodio2
|
||||
from tests import TestRevPiModIO
|
||||
|
||||
|
||||
class TestCompact(TestRevPiModIO):
|
||||
|
||||
data_dir = dirname(__file__)
|
||||
|
||||
def test_compact(self):
|
||||
rpi = self.modio(configrsc="config_compact.rsc")
|
||||
|
||||
self.assertIsInstance(rpi.core, revpimodio2.device.Compact)
|
||||
|
||||
# COMPACT LEDs prüfen
|
||||
self.assertEqual(rpi.io.RevPiLED.get_value(), b"\x00")
|
||||
rpi.core.A1 = revpimodio2.OFF
|
||||
self.assertEqual(rpi.core.A1, 0)
|
||||
rpi.core.A1 = revpimodio2.GREEN
|
||||
self.assertEqual(rpi.io.RevPiLED.get_value(), b"\x01")
|
||||
self.assertEqual(rpi.core.A1, 1)
|
||||
rpi.core.A1 = revpimodio2.RED
|
||||
self.assertEqual(rpi.io.RevPiLED.get_value(), b"\x02")
|
||||
self.assertEqual(rpi.core.A1, 2)
|
||||
with self.assertRaises(ValueError):
|
||||
rpi.core.A1 = 5
|
||||
|
||||
rpi.core.A2 = revpimodio2.OFF
|
||||
self.assertEqual(rpi.core.A2, 0)
|
||||
self.assertEqual(rpi.io.RevPiLED.get_value(), b"\x02")
|
||||
rpi.core.A2 = revpimodio2.GREEN
|
||||
self.assertEqual(rpi.io.RevPiLED.get_value(), b"\x06")
|
||||
self.assertEqual(rpi.core.A2, 1)
|
||||
rpi.core.A2 = revpimodio2.RED
|
||||
self.assertEqual(rpi.io.RevPiLED.get_value(), b"\x0a")
|
||||
self.assertEqual(rpi.core.A2, 2)
|
||||
with self.assertRaises(ValueError):
|
||||
rpi.core.A2 = 5
|
||||
|
||||
# Spezielle Werte aufrufen
|
||||
self.assertIsInstance(rpi.core.temperature, int)
|
||||
self.assertIsInstance(rpi.core.frequency, int)
|
||||
rpi.core.wd_toggle()
|
||||
|
||||
# Directzuweisung nicht erlaubt
|
||||
with self.assertRaisesRegex(AttributeError, r"direct assignment is not supported"):
|
||||
rpi.core.a1green = True
|
||||
|
||||
rpi.exit()
|
||||
del rpi
|
||||
|
||||
# Bit piCtory config
|
||||
rpi = self.modio(configrsc="config_compact_bits.json")
|
||||
del rpi
|
||||
Reference in New Issue
Block a user