Updated all test methods

parent 47209e42
from unittest import TestCase, main import os
import sys
from pprint import pprint as pp from pprint import pprint as pp
from unittest import TestCase, main
from dbus import SystemBus from dbus import SystemBus
import os, sys from plugins.functions.fmod_ssl import PEMFILE
SEPARATOR = "\n" + "-" * 30 + "\n" SEPARATOR = "\n" + "-" * 30 + "\n"
...@@ -62,6 +65,28 @@ class SettingsdTestCase(TestCase): ...@@ -62,6 +65,28 @@ class SettingsdTestCase(TestCase):
"ntp_config", "package_updates", "rtorrentd_config", "ssl", "ntp_config", "package_updates", "rtorrentd_config", "ssl",
"statistics", "system_services"] "statistics", "system_services"]
self.test_data_ = {
'servers': [],
"interface": [],
'range':['start_ip', 'stop_ip', 'netmask', 'lease'],
'staticHost':{'mac':None, 'ip':None, 'name':None},
'staticHostId':None,
'group':['TestName', 1234567],
'user':["TestUser"],
'dumpCurrentSettingsd': "dump_file.dump",
'reloadNetworkConfig':None,
'addRole': ['role_name', 'group_names_list'],
"ntpServers": [],
'downloadsDir': "/some/dir",
'sessionDir': 'some/another/dir',
'certficate': "filename",
'serviceName': "test_service"
}
with open(self.test_data_['certificate'], 'r') as cert:
data = cert.read()
self.test_data_['certificate'] = data
def test_auto(self): def test_auto(self):
for module_ in self.modules_list_: for module_ in self.modules_list_:
for res in self.autotest_.test_module(module_): for res in self.autotest_.test_module(module_):
...@@ -77,96 +102,127 @@ class SettingsdTestCase(TestCase): ...@@ -77,96 +102,127 @@ class SettingsdTestCase(TestCase):
self.assertEqual(test_(self), "Success") self.assertEqual(test_(self), "Success")
def test_dnsmasq_simple_setServers(self): def test_dnsmasq_simple_setServers(self):
pass self.autotest_.run_method("dnsmasq_simple", "setServers", self.test_data_['servers'])
self.assertEqual(self.autotest_.run_method('dnsmasq_simple', 'servers'), self.test_data_['servers'])
def test_dnsmasq_simple_setInterfaces(self): def test_dnsmasq_simple_setInterfaces(self):
pass self.autotest_.run_method("dnsmasq_simple", "setInterfaces", self.test_data_['interfaces'])
self.assertEqual(self.autotest_.run_method('dnsmasq_simple', 'interfaces'), self.test_data_['interfaces'])
def test_dnsmasq_simple_setExceptInterfaces(self): def test_dnsmasq_simple_setExceptInterfaces(self):
pass self.autotest_.run_method("dnsmasq_simple", "setExceptInterfaces", self.test_data_['interfaces'])
self.assertEqual(self.autotest_.run_method('dnsmasq_simple', 'exceptInterfaces'), self.test_data_['interfaces'])
def test_dnsmasq_simple_setRange(self): def test_dnsmasq_simple_setRange(self):
pass self.autotest_.run_method('dnsmasq_simple', 'setRange', self.test_data_['range'])
self.assertEqual(self.autotest_.run_method('dnsmasq_simple', 'range'), self.test_data_['range'])
def test_dnsmasq_simple_addStaticHost(self): def test_dnsmasq_simple_addStaticHost(self):
pass self.test_data_['save_static_host_list'] = self.autotest_.run_method('dnsmasq_simple', 'staticHosts')
self.autotest_.run_method('dnsmasq_simple', 'addStaticHost', self.test_data_['staticHost'])
self.assertListEqual(set(self.autotest_.run_method('dnsmasq_simple', 'staticHosts')).intersection(self.test_data_['staticHost']), self.test_data_['staticHosts'])
def test_dnsmasq_simple_removeStaticHost(self): def test_dnsmasq_simple_removeStaticHost(self):
pass #! How to get identifier?
self.autotest_.run_method('dnsmasq_simple', 'removeStaticHost', self.test_data_['staticHostId'])
self.assertListEqual(self.test_data_['save_static_host_lsit'], self.autotest_.run_method('dnsmasq_simple', 'staticHosts'))
def test_functions_localGroups_addGroup(self): def test_functions_localGroups_addGroup(self):
pass # what output?
out = self.autotest_.run_method('localGroups', 'addGroup', self.test_data_['group'])
def test_functions_localGroups_removeGroup(self): def test_functions_localGroups_removeGroup(self):
pass # what output?
out = self.autotest_.run_method('localGroups', 'removeGroup', self.test_data_['group'][0])
def test_functions_localUsers_addUser(self): def test_functions_localUsers_addUser(self):
pass self.test_data_['save_users_list'] = self.autotest_.run_method('localUsers', 'users')
out = self.autotest_.run_method('localUsers', 'addUser', self.test_data_['user'])
# output?
self.assertIn(self.test_data_['user'], self.test_data_['save_users_list'])
def test_functions_localUsers_removeUser(self): def test_functions_localUsers_removeUser(self):
pass self.autotest_.run_method('localUsers', 'removeUser', self.test_data_['user'])
self.assertListEqual(self.test_data_['save_users_list'], self.autotest_.run_method('localUsers', 'users'))
def test_functions_network_dumpCurrentSettingsd(self): def test_functions_network_dumpCurrentSettingsd(self):
pass self.autotest_.run_method('network', 'dumpCurrentSettingsd', self.test_data_['dumpCurrentSettingsd'])
self.assertTrue(os.path.exists(self.test_data_['dumpCurrentSettingsd']))
def test_functions_network_reloadNetworkConfig(self): def test_functions_network_reloadNetworkConfig(self):
pass self.autotest_.run_method('network', 'reloadNetworkConfig', self.test_data_['dumpCurrentSettingsd'])
def test_functions_nssRoles_addRole(self): def test_functions_nssRoles_addRole(self):
pass # role_name, group_names_list
self.assertEqual(self.autotest_.run_method('nssroles', 'addRole', self.test_data_['addRole']), 0)
def test_functions_nssRoles_removeRole(self): def test_functions_nssRoles_removeRole(self):
pass self.assertEqual(self.autotest_.run_method('nssroles', 'removeRole', self.test_data_['addRole'][0]), 0)
self.assertRaises(self.autotest_.run_method('nssroles', 'removeRole', self.test_data_['addRole'][0]))
def test_time_ntp_setServers(self): def test_time_ntp_setServers(self):
pass self.test_data_['save_ntp_servers_list'] = self.autotest_.run_method('ntp', 'servers')
self.autotest_.run_method('ntp', 'addServers', self.test_data_['ntpServers'])
self.assertIn(self.test_data_['ntpServers'], self.test_data_['save_ntp_servers_list'])
def test_rtorrent_daemon_setUser(self): def test_rtorrent_daemon_setUser(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setUser', self.test_data_['user'])
self.assertEqual(self.test_data_['user'], self.autotest_.run_method('rtorrent_daemon', 'user'))
def test_rtorrent_daemon_setDownloadsDir(self): def test_rtorrent_daemon_setDownloadsDir(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setDownloadsDir', self.test_data_['downloadsDir'])
self.assertEqual(self.test_data_['downloadsDir'], self.autotest_.run_method('rtorrent_daemon', 'downloadsDir'))
def test_rtorrent_daemon_setSessionDir(self): def test_rtorrent_daemon_setSessionDir(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setSessionDir', self.test_data_['sessionDir'])
self.assertEqual(self.test_data_['sessionDir'], self.autotest_.run_method('rtorrent_daemon', 'sessionDir'))
def test_rtorrent_daemon_setTmpDir(self): def test_rtorrent_daemon_setTmpDir(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setTmpDir', self.test_data_['tmpDir'])
self.assertEqual(self.test_data_['tmpDir'], self.autotest_.run_method('rtorrent_daemon', 'tmpDir'))
def test_rtorrent_daemon_setSocketPath(self): def test_rtorrent_daemon_setSocketPath(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setSocketPath', self.test_data_['socketPath'])
self.assertEqual(self.test_data_['socketPath'], self.autotest_.run_method('rtorrent_daemon', 'socketPath'))
def test_rtorrent_daemon_setSocketUser(self): def test_rtorrent_daemon_setSocketUser(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setSocketUser', self.test_data_['socketUser'])
self.assertEqual(self.test_data_['socketUser'], self.autotest_.run_method('rtorrent_daemon', 'socketUser'))
def test_rtorrent_daemon_setSockerGroup(self): def test_rtorrent_daemon_setSockerGroup(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setSockerGroup', self.test_data_['sockerGroup'])
self.assertEqual(self.test_data_['sockerGroup'], self.autotest_.run_method('rtorrent_daemon', 'sockerGroup'))
def test_rtorrent_daemon_setSocketMode(self): def test_rtorrent_daemon_setSocketMode(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setSocketMode', self.test_data_['socketMode'])
self.assertEqual(self.test_data_['socketMode'], self.autotest_.run_method('rtorrent_daemon', 'socketMode'))
def test_rtorrent_daemon_setRawConfigPath(self): def test_rtorrent_daemon_setRawConfigPath(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setRawConfigPath', self.test_data_['rawConfigPath'])
self.assertEqual(self.test_data_['rawConfigPath'], self.autotest_.run_method('rtorrent_daemon', 'rawConfigPath'))
def test_rtorrent_daemon_setRawConfig(self): def test_rtorrent_daemon_setRawConfig(self):
pass self.autotest_.run_method('rtorrent_daemon', 'setRawConfig', self.test_data_['rawConfig'])
self.assertEqual(self.test_data_['rawConfig'], self.autotest_.run_method('rtorrent_daemon', 'rawConfig'))
def test_functions_ssl_setCertificate(self): def test_functions_ssl_setCertificate(self):
pass self.assertTrue(self.autotest_.run_method('ssl', 'setCertificate', self.test_data_['certificate']))
with open(PEMFILE, 'r') as pemf:
self.assertEqual(pemf.read(), self.test_data_['certificate'])
def test_functions_systemService_enable(self): def test_functions_systemService_enable(self):
pass self.autotest_.run_method('systemService', 'enable', self.test_data_['serviceName'])
def test_functions_systemService_disable(self): def test_functions_systemService_disable(self):
pass self.autotest_.run_method('systemService', 'disable', self.test_data_['serviceName'])
def test_functions_systemService_reload(self): def test_functions_systemService_reload(self):
pass self.autotest_.run_method('systemService', 'reload', self.test_data_['serviceName'])
def test_functions_systemService_start(self): def test_functions_systemService_start(self):
pass self.autotest_.run_method('systemService', 'start', self.test_data_['serviceName'])
def test_functions_systemService_stop(self): def test_functions_systemService_stop(self):
pass self.autotest_.run_method('systemService', 'stop', self.test_data_['serviceName'])
Markdown is supported
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