From 2800f0b62c2936cd68c35623010c3f57d58b975d Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Mon, 2 Aug 2021 17:20:27 +0900 Subject: [PATCH] Fix broken unit test This change mocks sqlalchemy.update during unit tests properly to avoid the following error. sqlalchemy.exc.ArgumentError: subject table for an INSERT, UPDATE or DELETE expected, got Closes-Bug: #1938676 Change-Id: I5268132018e0a283bd35b5599cf8ca41968dde93 --- murano/tests/unit/db/services/test_instances.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/murano/tests/unit/db/services/test_instances.py b/murano/tests/unit/db/services/test_instances.py index 1e71ed53f..1144133ff 100644 --- a/murano/tests/unit/db/services/test_instances.py +++ b/murano/tests/unit/db/services/test_instances.py @@ -54,8 +54,10 @@ class TestInstances(test_base.MuranoTestCase): mock_db_session.get_session().add.assert_called_once_with( mock_models.Instance()) + @mock.patch('murano.db.services.instances.sqlalchemy') @mock.patch('murano.db.services.instances.models') - def test_track_instance_except_duplicate_entry(self, _, mock_db_session): + def test_track_instance_except_duplicate_entry(self, _, mock_sqlalchemy, + mock_db_session): mock_db_session.get_session().add.side_effect =\ exception.DBDuplicateEntry @@ -64,6 +66,7 @@ class TestInstances(test_base.MuranoTestCase): 'test_type_name', 'test_type_title') self.assertEqual(1, mock_db_session.get_session().execute.call_count) + self.assertEqual(1, mock_sqlalchemy.update().where.call_count) @mock.patch('murano.db.services.instances.timeutils') def test_destroy_instance(self, mock_timeutils, mock_db_session):