)]}'
{"/PATCHSET_LEVEL":[{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"2469662a4516c007cb8e556e994404e67cb1dc3f","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"6e702d0b_5821bb7e","updated":"2025-09-29 19:26:19.000000000","message":"Thanks for the eyes Ash!","commit_id":"9009af4b9695b44af75677f3a17c53f2b3b7a01a"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"d2a772f2d5940eaf0005b87dc7eb45c22e5b32a1","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":1,"id":"0b9277d2_db14c102","updated":"2025-09-29 15:44:21.000000000","message":"parent/master:\n\n```\nvagrant@saio:~$ pytest swift/test/unit/account/test_backend.py -vsx | grep _path\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeMetadata::test_path_best_effort_when_partial_attrs PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeMetadata::test_path_lazy_populates_from_db PASSED\n```\n\nthis change:\n\n```\nvagrant@saio:~$ pytest swift/test/unit/account/test_backend.py -vsx | grep _path\nswift/test/unit/account/test_backend.py::TestAccountBroker::test_path_caches_account PASSED\nswift/test/unit/account/test_backend.py::TestAccountBroker::test_path_on_uninitialized_broker PASSED\nswift/test/unit/account/test_backend.py::TestAccountBroker::test_path_uses_account_kwag PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeMetadata::test_path_caches_account PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeMetadata::test_path_on_uninitialized_broker PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeMetadata::test_path_uses_account_kwag PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeSPI::test_path_caches_account PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeSPI::test_path_on_uninitialized_broker PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforeSPI::test_path_uses_account_kwag PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforePerPolicyContainerTrack::test_path_caches_account PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforePerPolicyContainerTrack::test_path_on_uninitialized_broker PASSED\nswift/test/unit/account/test_backend.py::TestAccountBrokerBeforePerPolicyContainerTrack::test_path_uses_account_kwag PASSED\n```","commit_id":"9009af4b9695b44af75677f3a17c53f2b3b7a01a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"fd406858afd63d58234270de114371abe7dbadaa","unresolved":false,"context_lines":[],"source_content_type":"","patch_set":2,"id":"eae82668_a4dfd5c0","updated":"2025-10-06 09:59:53.000000000","message":"LGTM, I added Related-Change to the commit message","commit_id":"a01601c62c673619316fff2a9ed2d9b12b634b65"}],"test/unit/account/test_backend.py":[{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"fd406858afd63d58234270de114371abe7dbadaa","unresolved":true,"context_lines":[{"line_number":1124,"context_line":"        db_file \u003d self.get_db_path()"},{"line_number":1125,"context_line":"        b \u003d AccountBroker(db_file, account\u003daccount)"},{"line_number":1126,"context_line":"        b.initialize(Timestamp(\u00271\u0027).internal)"},{"line_number":1127,"context_line":"        return db_file"},{"line_number":1128,"context_line":""},{"line_number":1129,"context_line":"    def test_path_caches_account(self):"},{"line_number":1130,"context_line":"        db_file \u003d self._create_db()"}],"source_content_type":"text/x-python","patch_set":1,"id":"2e487367_99d6f405","line":1127,"updated":"2025-10-06 09:59:53.000000000","message":"+1 don\u0027t use the *broker* that we just called ``initialize`` on for the test assertions","commit_id":"9009af4b9695b44af75677f3a17c53f2b3b7a01a"},{"author":{"_account_id":7847,"name":"Alistair Coles","email":"alistairncoles@gmail.com","username":"acoles"},"change_message_id":"fd406858afd63d58234270de114371abe7dbadaa","unresolved":true,"context_lines":[{"line_number":1136,"context_line":""},{"line_number":1137,"context_line":"        def capture_get_info(self):"},{"line_number":1138,"context_line":"            called[\u0027n\u0027] +\u003d 1"},{"line_number":1139,"context_line":"            return orig_get_info(self)"},{"line_number":1140,"context_line":""},{"line_number":1141,"context_line":"        self.assertEqual(0, called[\u0027n\u0027])"},{"line_number":1142,"context_line":"        with mock.patch.object(AccountBroker, \u0027get_info\u0027, capture_get_info):"}],"source_content_type":"text/x-python","patch_set":1,"id":"978e63a8_4e02be7d","line":1139,"updated":"2025-10-06 09:59:53.000000000","message":"I\u0027ve often been frustrated at having to write this somewhat verbose kind of mock method that just wants to capture calls and pass-through to the original without modifying any behavior. I only recently realised that ``side_effect`` can be used to achieve the same:\n\n```\ndiff --git a/test/unit/account/test_backend.py b/test/unit/account/test_backend.py\nindex 7b8cf44ca..da70bf9bb 100644\n--- a/test/unit/account/test_backend.py\n+++ b/test/unit/account/test_backend.py\n@@ -1130,19 +1130,12 @@ class TestAccountBroker(test_db.TestDbBase):\n         db_file \u003d self._create_db()\n         b \u003d AccountBroker(db_file)\n         self.assertIsNone(b.account)\n-        called \u003d {\u0027n\u0027: 0}\n-\n-        orig_get_info \u003d AccountBroker.get_info\n-\n-        def capture_get_info(self):\n-            called[\u0027n\u0027] +\u003d 1\n-            return orig_get_info(self)\n \n-        self.assertEqual(0, called[\u0027n\u0027])\n-        with mock.patch.object(AccountBroker, \u0027get_info\u0027, capture_get_info):\n+        with mock.patch.object(\n+                b, \u0027get_info\u0027, side_effect\u003db.get_info) as mock_get_info:\n             self.assertEqual(\u0027a\u0027, b.path)\n             # accessing path will call get_info!\n-            self.assertEqual(1, called[\u0027n\u0027])\n+            self.assertEqual(1, len(mock_get_info.call_args_list))\n             # and populate the account attribute\n             self.assertEqual(\u0027a\u0027, b.account)\n             # it\u0027s cached\n@@ -1150,7 +1143,7 @@ class TestAccountBroker(test_db.TestDbBase):\n                 self.assertEqual(\u0027a\u0027, b.path)\n                 self.assertEqual(\u0027a\u0027, b.account)\n         # we only call get_info once\n-        self.assertEqual(1, called[\u0027n\u0027])\n+        self.assertEqual(1, len(mock_get_info.call_args_list))\n \n     def test_path_uses_account_kwag(self):\n         db_file \u003d self._create_db()\n\n```","commit_id":"9009af4b9695b44af75677f3a17c53f2b3b7a01a"},{"author":{"_account_id":34892,"name":"ASHWIN A NAIR","display_name":"indianwhocodes","email":"nairashwin952013@gmail.com","username":"indianwhocodes","status":"Nvidia"},"change_message_id":"7f8bde8e6fc60f26f035530bdc3be83fcf0c27ba","unresolved":false,"context_lines":[{"line_number":1180,"context_line":"        with self.assertRaises(ValueError) as ctx:"},{"line_number":1181,"context_line":"            b.initialize(next(self.ts))"},{"line_number":1182,"context_line":"        self.assertEqual("},{"line_number":1183,"context_line":"            \u0027Attempting to create a new database with no account set\u0027,"},{"line_number":1184,"context_line":"            str(ctx.exception))"},{"line_number":1185,"context_line":"        b.account \u003d \u0027a\u0027"},{"line_number":1186,"context_line":"        self.assertEqual(\u0027a\u0027, b.path)"}],"source_content_type":"text/x-python","patch_set":1,"id":"f0569d2f_9af164d5","line":1183,"updated":"2025-09-29 19:01:59.000000000","message":"This was missing in the existing test coverage, thanks for writing this!","commit_id":"9009af4b9695b44af75677f3a17c53f2b3b7a01a"},{"author":{"_account_id":1179,"name":"Clay Gerrard","email":"clay.gerrard@gmail.com","username":"clay-gerrard"},"change_message_id":"2469662a4516c007cb8e556e994404e67cb1dc3f","unresolved":false,"context_lines":[{"line_number":1180,"context_line":"        with self.assertRaises(ValueError) as ctx:"},{"line_number":1181,"context_line":"            b.initialize(next(self.ts))"},{"line_number":1182,"context_line":"        self.assertEqual("},{"line_number":1183,"context_line":"            \u0027Attempting to create a new database with no account set\u0027,"},{"line_number":1184,"context_line":"            str(ctx.exception))"},{"line_number":1185,"context_line":"        b.account \u003d \u0027a\u0027"},{"line_number":1186,"context_line":"        self.assertEqual(\u0027a\u0027, b.path)"}],"source_content_type":"text/x-python","patch_set":1,"id":"df0c401b_72cb824b","line":1183,"in_reply_to":"f0569d2f_9af164d5","updated":"2025-09-29 19:26:19.000000000","message":"Yeah the account-server is going to tend to say:\n\n```\nb \u003d AccountBroker(db_file, account\u003daccount)\nb.initialize()\n```\n\n... sort of like _create_db\n\nWhere as the replicator is going to say:\n\n```\nb \u003d AccountBroker(db_file)\nb.get_info()\n```\n\nThe later would already blow up if db_file doesn\u0027t exist - and the former would blow-up if you forget to pass in account\n\nSo, I think the ConnectionError on \"db_file does not exist\" is ok, but I sort of wanted a test to help me make sure I understand it.  If we have a bug at somepoint related to the order of operations with path and get_info and account hopefully this test will at least confirm the code was working when we wrote it as best as we understood requirements at the time!","commit_id":"9009af4b9695b44af75677f3a17c53f2b3b7a01a"}]}
