diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-08-23 22:12:00 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-08-23 22:12:00 +0200 |
commit | a4b064ea73f0d6255f868ad3dec620cad8060f9a (patch) | |
tree | b4f29d3ac479119e28be5460436614818ca904ba | |
parent | 71a2e3fad3bd773391196f84171c606cad2e3516 (diff) | |
download | vyos-1x-a4b064ea73f0d6255f868ad3dec620cad8060f9a.tar.gz vyos-1x-a4b064ea73f0d6255f868ad3dec620cad8060f9a.zip |
lcd: adjust to cli changes
-rwxr-xr-x | scripts/cli/test_system_lcd.py | 103 |
1 files changed, 11 insertions, 92 deletions
diff --git a/scripts/cli/test_system_lcd.py b/scripts/cli/test_system_lcd.py index f9fb00aa5..931a91c53 100755 --- a/scripts/cli/test_system_lcd.py +++ b/scripts/cli/test_system_lcd.py @@ -14,32 +14,16 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. -import re import os import unittest -import configparser +from configparser import ConfigParser from psutil import process_iter -from vyos.configsession import ConfigSession, ConfigSessionError -from vyos.util import read_file +from vyos.configsession import ConfigSession -base_path = ['system', 'display'] +base_path = ['system', 'lcd'] -""" - system display model (sdec|ezio) - system display show host (cpu|cpu-all|cpu-hist|disk|load-hist|memory|proc|uptime) - network interface <intName> alias <alias> - units (bps|Bps|pps) - clock (big|mini|date-time) - title <name> - - system display time <s> - system display hello <string> - system display bye <string> - system display disabled -""" - -class SystemDisplayTest(unittest.TestCase): +class TestSystemLCD(unittest.TestCase): def setUp(self): self.session = ConfigSession(os.getpid()) @@ -50,86 +34,21 @@ class SystemDisplayTest(unittest.TestCase): def test_system_display(self): # configure some system display - self.session.set(base_path + ['hello', 'Welcome to VyOS']) - self.session.set(base_path + ['bye', 'Bye from VyOS']) - self.session.set(base_path + ['time', '30']) - - # check validate() - a model and a show are required - with self.assertRaises(ConfigSessionError): - self.session.commit() - - self.session.set(base_path + ['model', 'ezio']) - - # check validate() - a show required - with self.assertRaises(ConfigSessionError): - self.session.commit() - - self.session.set(base_path + ['show', 'clock', 'big']) - - self.session.set(base_path + ['show', 'network', 'units', 'pps']) - self.session.set(base_path + ['show', 'network', 'interface', 'eth0', 'alias', 'WAN']) - self.session.set(base_path + ['show', 'network', 'interface', 'eth1', 'alias', 'LAN']) - self.session.set(base_path + ['show', 'network', 'interface', 'eth2', 'alias', 'WIFI']) - # One too many - self.session.set(base_path + ['show', 'network', 'interface', 'eth3']) - - # check validate() - more then 3 interfaces - with self.assertRaises(ConfigSessionError): - self.session.commit() - - self.session.delete(base_path + ['show', 'network', 'interface', 'eth3']) + self.session.set(base_path + ['device', 'ttyS1']) + self.session.set(base_path + ['model', 'cfa-533']) # commit changes self.session.commit() # load up ini-styled LCDd.conf - LCDd_conf = configparser.ConfigParser() - LCDd_conf.read('/run/LCDd/LCDd.lo.conf') - - # Check settings made it into LCDd.conf - self.assertTrue(LCDd_conf['server']['Driver'] == 'hd44780') - self.assertTrue(LCDd_conf['server']['Hello'] == '"Welcome to VyOS"') - self.assertTrue(LCDd_conf['server']['GoodBye'] == '"Bye from VyOS"') - self.assertTrue(LCDd_conf['server']['WaitTime'] == '30') - - self.assertTrue(LCDd_conf['hd44780']['ConnectionType'] == 'ezio') - self.assertTrue(LCDd_conf['hd44780']['Keypad'] == 'yes') - self.assertTrue(LCDd_conf['hd44780']['Size'] == '16x2') - self.assertTrue(LCDd_conf['hd44780']['KeyMatrix_4_1'] == 'Enter') - self.assertTrue(LCDd_conf['hd44780']['KeyMatrix_4_2'] == 'Up') - self.assertTrue(LCDd_conf['hd44780']['KeyMatrix_4_3'] == 'Down') - self.assertTrue(LCDd_conf['hd44780']['KeyMatrix_4_4'] == 'Escape') - #self.assertTrue(LCDd_conf['hd44780']['Device'] == '/dev/ttyS1') - - # load up ini-styled lcdproc.conf configuration file - lcdproc_conf = configparser.ConfigParser() + conf = ConfigParser() + conf.read('/run/LCDd/LCDd.conf') - lcdproc_conf.read('/run/lcdproc/lcdproc.lo.conf') - # clock - self.assertTrue(lcdproc_conf['TimeDate']['Active'] == 'false') - self.assertTrue(lcdproc_conf['BigClock']['Active'] == 'true') - self.assertTrue(lcdproc_conf['MiniClock']['Active'] == 'false') - # host - self.assertTrue(lcdproc_conf['CPU']['Active'] == 'false') - self.assertTrue(lcdproc_conf['Memory']['Active'] == 'false') - self.assertTrue(lcdproc_conf['Load']['Active'] == 'false') - # network - self.assertTrue(lcdproc_conf['Iface']['Active'] == 'true') - self.assertTrue(lcdproc_conf['Iface']['Interface0'] == 'eth0') - self.assertTrue(lcdproc_conf['Iface']['Alias0'] == 'WAN') - self.assertTrue(lcdproc_conf['Iface']['Interface1'] == 'eth1') - self.assertTrue(lcdproc_conf['Iface']['Alias1'] == 'LAN') - self.assertTrue(lcdproc_conf['Iface']['Interface2'] == 'eth2') - self.assertTrue(lcdproc_conf['Iface']['Alias2'] == 'WIFI') - self.assertTrue(lcdproc_conf['Iface']['unit'] == 'packet') - # Check if LCdd and lcdproc are running - running = 0 - for p in process_iter(): - if p.name() in ['lcdproc', 'LCDd']: - running += 1 + self.assertEqual(conf['CFontzPacket']['Model'], '533') + self.assertEqual(conf['CFontzPacket']['Device'], '/dev/ttyS1') # both processes running - self.assertTrue(running == 2) + self.assertTrue('LCDd' in (p.name() for p in process_iter())) if __name__ == '__main__': unittest.main() |