Convert base commands to ReadOnlyCommand

This adds a test for handling nested read-only execute() commands
and converts some commands that were missed.

Related-Bug: #1813213
Change-Id: I77332f1810fe09f8bce8c41cc11168b15923ecce
This commit is contained in:
Terry Wilson 2019-01-25 11:17:08 -06:00 committed by Lucas Alvares Gomes
parent 210be9fb1a
commit 923abc1bf0
2 changed files with 7 additions and 3 deletions

View File

@ -180,7 +180,7 @@ class DbClearCommand(BaseCommand):
setattr(record, self.column, value)
class DbGetCommand(BaseCommand):
class DbGetCommand(ReadOnlyCommand):
def __init__(self, api, table, record, column):
super(DbGetCommand, self).__init__(api)
self.table = table
@ -200,7 +200,7 @@ class DbGetCommand(BaseCommand):
self.result = result
class DbListCommand(BaseCommand):
class DbListCommand(ReadOnlyCommand):
def __init__(self, api, table, records, columns, if_exists, row=False):
super(DbListCommand, self).__init__(api)
self.table = table
@ -265,7 +265,7 @@ class DbListCommand(BaseCommand):
match=records_found[0])
class DbFindCommand(BaseCommand):
class DbFindCommand(ReadOnlyCommand):
def __init__(self, api, table, *conditions, **kwargs):
super(DbFindCommand, self).__init__(api)
self.table = self.api._tables[table]

View File

@ -69,6 +69,10 @@ class TestBackendDb(base.FunctionalTestCase):
columns=('name', 'datapath_type')).execute(check_error=True)
self.assertTrue(all(b in res for b in self.bridges))
def test_db_list_nested(self):
with self.api.transaction(check_error=True):
self.test_db_list()
def test_db_list_record(self):
res = self.api.db_list(
'Bridge', [self.bridges[0]['name']],