How to use convert_sysv_runlevel method in avocado

Best Python code snippet using avocado_python

service_unittest.py

Source:service_unittest.py Github

copy

Full Screen

...134 assert list_result == {'sshd': "enabled",135 'vsftpd': "disabled",136 'systemd-sysctl': "static"}137 def test_set_default_runlevel(self):138 runlevel = service.convert_sysv_runlevel(3)139 mktemp_mock = MagicMock(return_value="temp_filename")140 symlink_mock = MagicMock()141 rename_mock = MagicMock()142 @patch.object(service, "mktemp", mktemp_mock)143 @patch("os.symlink", symlink_mock)144 @patch("os.rename", rename_mock)145 def _():146 self.service_manager.change_default_runlevel(runlevel)147 assert mktemp_mock.called148 assert symlink_mock.call_args[0][149 0] == "/usr/lib/systemd/system/multi-user.target"150 assert rename_mock.call_args[0][151 1] == "/etc/systemd/system/default.target"152 _()153 def test_unknown_runlevel(self):154 self.assertRaises(ValueError,155 service.convert_systemd_target_to_runlevel, "unknown")156 def test_runlevels(self):157 assert service.convert_sysv_runlevel(0) == "poweroff.target"158 assert service.convert_sysv_runlevel(1) == "rescue.target"159 assert service.convert_sysv_runlevel(2) == "multi-user.target"160 assert service.convert_sysv_runlevel(5) == "graphical.target"161 assert service.convert_sysv_runlevel(6) == "reboot.target"162class TestSysVInitServiceManager(TestServiceManager):163 def setUp(self):164 self.run_mock = MagicMock()165 self.init_name = "init"166 self.service_manager = super(TestSysVInitServiceManager,167 self).get_service_manager_from_init_and_run(self.init_name,168 self.run_mock)169 def test_list(self):170 list_result_mock = MagicMock(exit_status=0,171 stdout="sshd 0:off 1:off 2:off 3:off 4:off 5:off 6:off\n"172 "vsftpd 0:off 1:off 2:off 3:off 4:off 5:on 6:off\n"173 "xinetd based services:\n"174 " amanda: off\n"175 " chargen-dgram: on\n")...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run avocado automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful