def initialize_app(app, home_endpoint=None): models.connect() @app.before_request def _db_connect(): models.database.connect() @app.teardown_request def _db_close(exc): if not models.database.is_closed(): models.database.commit() models.database.close() admin = Admin(app, name='Raw Table Admin', template_mode='bootstrap3') if home_endpoint: admin.add_link( MenuLink("Devtest Main", url="/", endpoint=home_endpoint)) admin.add_views(TestBedView(), EquipmentModelView(), EquipmentView(), NetworksView(), InterfacesView(), ConnectionView(), AccountIdsView(), TestequipmentView()) admin.add_views(SoftwareView(), SoftwareVariantView(), FunctionView()) admin.add_views(ScenarioView(), TestSuiteView(), TestCaseView(), TestResultsView()) admin.add_view(RadarComponentView())
def pick_testbed(): from devtest.ui import simpleui from devtest.db import models models.connect() tblist = models.TestBed.get_list() return simpleui.choose(tblist, defidx=tblist.index("default"), prompt="Choose testbed")
def list_testbeds(verbose): from devtest.db import models models.connect() print("Available testbeds:") if verbose: for tb in models.TestBed.select(): print(" ", colors.green(tb.name)) for te in tb.testequipment: print(" ", te.equipment.name, "role:", te.function.name) else: for tb in models.TestBed.get_list(): print(" ", colors.green(tb))
def get_testbed(name, storageurl=None, debug=False): """Entry point for Testbed, container of the device tree. Returns: TestBedRuntime initialized from the testbed in the database. """ models.connect(storageurl) try: testbed = models.TestBed.select().where( models.TestBed.name == name).get() except models.DoesNotExist as err: raise ConfigError("Bad TestBed name {!r}: {}".format(name, err)) from None return TestBedRuntime(testbed, debug=debug)
def initialize(self, config=None): super().initialize(config=config) self._tci = testcases_importer.TestcasesImporter() models.connect() self._resultstack = []