Refactor all python test libraries to conform to python coding guidelines
Refactor robot Test Case Suite to conform to Robot code coding guidelines
Now that I have pycharm installed in a cloned VM that I resized to allow for
development tools, I see coding issues with the original code that I had
This is mostly a cosmetic change as no fundamental changes were made
to the original code
Rebased and fixed conflicts
Change-Id: I5dc0534e92fa708b45399944994101afd7efed63
diff --git a/tests/atests/common/preprovisioning.py b/tests/atests/common/preprovisioning.py
index 81cfd8a..affa991 100755
--- a/tests/atests/common/preprovisioning.py
+++ b/tests/atests/common/preprovisioning.py
@@ -19,11 +19,10 @@
"""
import time
-import os
-import commands
import testCaseUtils
import logging
+
class Preprovisioning(object):
"""
@@ -31,10 +30,10 @@
"""
def __init__(self):
- self.dirs = {}
- self.dirs ['log'] = None
- self.dirs ['root'] = None
- self.dirs ['voltha'] = None
+ self.dirs = dict()
+ self.dirs['log'] = None
+ self.dirs['root'] = None
+ self.dirs['voltha'] = None
self.__oltIpAddress = None
self.__oltPort = None
@@ -43,20 +42,20 @@
self.__fields = []
self.__oltDeviceId = None
- def pSetLogDirs(self, logDir):
- testCaseUtils.configDirs(self, logDir)
+ def p_set_log_dirs(self, log_dir):
+ testCaseUtils.config_dirs(self, log_dir)
- def pConfigure(self, oltIpAddress, oltPort, oltType, onuType):
- self.__oltIpAddress = oltIpAddress
- self.__oltPort = oltPort
- self.__oltType = oltType
- self.__onuType = onuType
+ def p_configure(self, olt_ip_address, olt_port, olt_type, onu_type):
+ self.__oltIpAddress = olt_ip_address
+ self.__oltPort = olt_port
+ self.__oltType = olt_type
+ self.__onuType = onu_type
- def preprovisionOlt(self):
+ def preprovision_olt(self):
logging.info('Do PROVISIONING')
- testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
- 'voltha_preprovision_olt.log', 'preprovision_olt -t ponsim_olt -H %s:%s' %
- (self.__oltIpAddress, self.__oltPort))
+ testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_preprovision_olt.log', 'preprovision_olt -t ponsim_olt -H %s:%s' %
+ (self.__oltIpAddress, self.__oltPort))
time.sleep(5)
def status_should_be_success_after_preprovision_command(self):
@@ -64,15 +63,15 @@
assert statusLines, 'Preprovision Olt command should have returned success but did not'
def query_devices_before_enabling(self):
- testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
- 'voltha_devices_before_enable.log', 'devices')
- testCaseUtils.printLogFile (self, 'voltha_devices_before_enable.log')
+ testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_devices_before_enable.log', 'devices')
+ testCaseUtils.print_log_file(self, 'voltha_devices_before_enable.log')
time.sleep(5)
def check_olt_fields_before_enabling(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_before_enable.log')
assert statusLines, 'No Olt listed under devices'
- self.__fields = testCaseUtils.parseFields(statusLines)
+ self.__fields = testCaseUtils.parse_fields(statusLines)
self.__oltDeviceId = self.__fields[1].strip()
logging.debug("OLT device id = %s" % self.__oltDeviceId)
adminState = self.__fields[3].strip()
@@ -83,20 +82,20 @@
assert hostPortFields[0].strip() == self.__oltIpAddress or hostPortFields[1] == str(self.__oltPort), \
'Olt IP or Port does not match'
- def check_states(self, devType):
+ def check_states(self, dev_type):
result = True
adminState = self.__fields[7].strip()
- assert adminState == 'ENABLED', 'Admin State of %s not ENABLED' % devType
- operStatus = self.__fields[8].strip()
- assert operStatus == 'ACTIVE', 'Oper Status of %s not ACTIVE' % devType
+ assert adminState == 'ENABLED', 'Admin State of %s not ENABLED' % dev_type
+ operatorStatus = self.__fields[8].strip()
+ assert operatorStatus == 'ACTIVE', 'Operator Status of %s not ACTIVE' % dev_type
connectStatus = self.__fields[9].strip()
- assert connectStatus == 'REACHABLE', 'Connect Status of %s not REACHABLE' % devType
+ assert connectStatus == 'REACHABLE', 'Connect Status of %s not REACHABLE' % dev_type
return result
def check_olt_fields_after_enabling(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, self.__oltType, 'voltha_devices_after_enable.log')
assert statusLines, 'No Olt listed under devices'
- self.__fields = testCaseUtils.parseFields(statusLines)
+ self.__fields = testCaseUtils.parse_fields(statusLines)
assert self.check_states(self.__oltType), 'States of %s does match expected' % self.__oltType
hostPort = self.__fields[11].strip()
assert hostPort, 'hostPort field is empty'
@@ -111,28 +110,29 @@
lenLines = len(lines)
assert lenLines == 1, 'Fixed single onu does not match, ONU Count was %d' % lenLines
for line in lines:
- self.__fields = testCaseUtils.parseFields(line)
- assert self.check_states(self.__onuType) == True, 'States of %s does match expected' % self.__onuType
+ self.__fields = testCaseUtils.parse_fields(line)
+ assert (self.check_states(self.__onuType) is True), 'States of %s does match expected' % self.__onuType
def enable(self):
logging.info('Enable %s OLT device' % self.__oltDeviceId)
- testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
- 'voltha_enable.log', 'enable ' + self.__oltDeviceId)
+ testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_enable.log', 'enable ' + self.__oltDeviceId)
def status_should_be_success_after_enable_command(self):
statusLines = testCaseUtils.get_fields_from_grep_command(self, 'success', 'voltha_enable.log')
assert statusLines, 'Enable command should have returned success but did not'
def query_devices_after_enabling(self):
- testCaseUtils.send_command_to_voltha_cli(testCaseUtils.getDir(self, 'log'),
- 'voltha_devices_after_enable.log', 'devices')
- testCaseUtils.printLogFile (self, 'voltha_devices_after_enable.log')
+ testCaseUtils.send_command_to_voltha_cli(testCaseUtils.get_dir(self, 'log'),
+ 'voltha_devices_after_enable.log', 'devices')
+ testCaseUtils.print_log_file(self, 'voltha_devices_after_enable.log')
-def runTest(oltIpAddress, oltPort, oltType, onuType, logDir):
+
+def run_test(olt_ip_address, olt_port, olt_type, onu_type, log_dir):
preprovisioning = Preprovisioning()
- preprovisioning.pSetLogDirs(logDir)
- preprovisioning.pConfigure(oltIpAddress, oltPort, oltType, onuType)
- preprovisioning.preprovisionOlt()
+ preprovisioning.p_set_log_dirs(log_dir)
+ preprovisioning.p_configure(olt_ip_address, olt_port, olt_type, onu_type)
+ preprovisioning.preprovision_olt()
preprovisioning.status_should_be_success_after_preprovision_command()
preprovisioning.query_devices_before_enabling()
preprovisioning.check_olt_fields_before_enabling()
@@ -141,6 +141,3 @@
preprovisioning.query_devices_after_enabling()
preprovisioning.check_olt_fields_after_enabling()
preprovisioning.check_onu_fields_after_enabling()
-
-
-