I'm writing some Python (3.4.2) scripts to telnet into our legacy VMS system to run some reports. The terminal emulation we use to access the system is VT320.
I want to use TDD into my scripts to help verify I'm at the right menu before proceeding.
Below is the start of my script. I'm not sure how to incorporate:
If test1 passes, do step1
If test2 passes, do step2
etc.
Has anyone incorporated TDD into a Python Telnet script to verify your location within the remote system?
Where do I go from here?
import unittest
import re
import telnetlib
timeout = 120
dataqueue = ""
f = open('datafile.txt', 'w')
class ConnectionTest(unittest.TestCase):
def test_connection_to_Legacy_System(self):
a = "---Test---"
self.assertIsNone(a)
if __name__ == "__main__":
unittest.main()
tn = telnetlib.Telnet(HOST,23,timeout)
tn.read_until(b"YOUR ID:")
tn.write(str.encode(user + "\r\n"))
tn.read_until(b"PASSWORD:")
tn.write(str.encode(password + "\r\n"))
tn.read_until(b"Selection: ")
tn.write("1\r\n")
dataqueue = tn.read_very_eager()
dataqueue = dataqueue.decode('ascii')
tn.close()
f.write(dataqueue)
f.close()