From 547777a9cfc6fd0be667bae17ab503b49b705116 Mon Sep 17 00:00:00 2001 From: Terry Wilson Date: Fri, 25 Jan 2019 11:17:08 -0600 Subject: [PATCH] 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 --- ovsdbapp/backend/ovs_idl/command.py | 6 +++--- .../tests/functional/schema/open_vswitch/test_common_db.py | 4 ++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ovsdbapp/backend/ovs_idl/command.py b/ovsdbapp/backend/ovs_idl/command.py index 78c036ed..9756de94 100644 --- a/ovsdbapp/backend/ovs_idl/command.py +++ b/ovsdbapp/backend/ovs_idl/command.py @@ -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 @@ -263,7 +263,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] diff --git a/ovsdbapp/tests/functional/schema/open_vswitch/test_common_db.py b/ovsdbapp/tests/functional/schema/open_vswitch/test_common_db.py index 5f0a106c..66ceb48c 100644 --- a/ovsdbapp/tests/functional/schema/open_vswitch/test_common_db.py +++ b/ovsdbapp/tests/functional/schema/open_vswitch/test_common_db.py @@ -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']],