Files
wlan-lanforge-scripts/py-json/test_base.py
erinnerim 1d7578251c Updates to import statements:
- Import importlib, os, and sys to each python script.
 - Append "lanforge-scripts" root directory to the system path, allowing each script to be called from an antecedent directory. e.g.
if 'lanforge-scripts' not in sys.path:
    sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../../")))
 - All statements of the form 'from <module> import <class>' replace with:
<module> = importlib.import_module("lanforge-scripts.<directory>.<module>")
<class> = <module>.<class>
2021-09-15 16:17:16 -07:00

79 lines
2.2 KiB
Python

#!/usr/bin/env python3
import sys
import os
import importlib
if 'lanforge-scripts' not in sys.path:
sys.path.append(os.path.join(os.path.abspath(__file__ + "../../../../")))
lfdata = importlib.import_module("lanforge-scripts.py-json.lfdata")
LFDataCollection = lfdata.LFDataCollection
class TestBase:
def __init__(self):
self.profiles = list()
def pre_clean_up(self):
if self.profiles:
for profile in self.profiles:
profile.precleanup()
def clean_up(self):
if self.profiles:
for profile in self.profiles:
profile.cleanup()
def start(self):
if self.profiles:
for profile in self.profiles:
profile.start()
def stop(self):
if self.profiles:
for profile in self.profiles:
profile.stop()
def build(self):
# - create station profile
# - create 2 criteria [ex: not down, continually_receiving] object (for ex)
# - station_profile.add_criteria([not_down, continually_receiving, etc_3])
# design - inversion of control
if self.profiles:
for profile in self.profiles:
profile.build()
def passes(self):
if self.profiles:
for profile in self.profiles:
profile.check_passes()
def run_duration(self, monitor_enabled= False):
#here check if monitor is enabled or not, then run loop accordingly
self.check_for_halt()
if self.profiles:
if monitor_enabled:
for profile in self.profiles:
profile.monitor_record() #check for halt in monitor record?
for profile in self.profiles:
profile.grade()
if self.exit_on_fail:
if self.fails():
self.exit_fail()
self.check_for_quit()
def report(self, enabled= False):
#here check if monitor is enabled or not, then run loop accordingly with lfreporting
pass
def begin(self):
self.pre_clean_up()
self.build()
self.start()
self.run_duration()
self.stop()
self.report()
self.clean_up()