blob: fd57bfbd425722ef30fc5feb19238a92ceca75ce [file] [log] [blame]
"""This class is a parent class for all subordniate "testcase_" classes.
This class is a parent class for all subordniate "testcase_" classes such as,,, and
It uses telnetlib to connect to telnet in order to communicate with emulator.
There is some sync problem or potential bug in emualtor, particularly observable
when run on Windows machine:
The issue was handled by giving timeout parameter to the read_until function
of python telnetlib and give wait time of 0.5 after each write onto the telnet
import inspect
import sys
import unittest
from utils import util
class BaseConsoleTest(unittest.TestCase):
"""This is the base clase for fall console test."""
def __init__(self, method_name=None, avd=None):
if method_name:
super(BaseConsoleTest, self).__init__(method_name)
super(BaseConsoleTest, self).__init__()
self.avd = avd
def setUp(self):
auth_token = util.get_auth_token()
self.telnet = util.telnet_emulator()
self.telnet.write('%s %s\n' % (util.AUTH, auth_token))
if (not util.check_read_until(
self.telnet.read_until(util.OK, util.TIMEOUT_S))):
def tearDown(self):
def assert_cmd_successful(self, is_cmd_successful, assertion_msg, has_status,
status, expected, actual):
if has_status:
print ('Test result: %s status matches %s => %s' %
(inspect.stack()[0][3], status, str(is_cmd_successful)))
print ('Test result: %s => %s' %
(inspect.stack()[0][3], str(is_cmd_successful)))
if not is_cmd_successful:
print 'Expected output:'
print expected
print 'Actual Output:'
print actual
self.assertTrue(is_cmd_successful, assertion_msg)
if __name__ == '__main__':
print '======= Base Console Test ======='