)]}'
{"nova/compute/manager.py":[{"author":{"_account_id":6062,"name":"jichenjc","email":"jichenjc@cn.ibm.com","username":"jichenjc"},"change_message_id":"7141ec77b2c0356cfc9fa84f5157ad3f0379b912","unresolved":false,"context_lines":[{"line_number":3019,"context_line":"                for bdm in bdms:"},{"line_number":3020,"context_line":"                    if bdm.is_volume:"},{"line_number":3021,"context_line":"                        self.detach_volume(context, bdm.volume_id, instance,"},{"line_number":3022,"context_line":"                                           destroy_bdm\u003dFalse)"},{"line_number":3023,"context_line":""},{"line_number":3024,"context_line":"            files \u003d self._decode_files(injected_files)"},{"line_number":3025,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"bab921fb_e6bc646e","line":3022,"updated":"2015-04-23 16:36:20.000000000","message":"question: \nis this applied to both rebuild and evacuate? just curious..","commit_id":"2cfad889d8a335b85a319b39ebfb243744bae9ca"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"32313d5c8ed90fe688e084a5a61335a06748a4e8","unresolved":false,"context_lines":[{"line_number":3019,"context_line":"                for bdm in bdms:"},{"line_number":3020,"context_line":"                    if bdm.is_volume:"},{"line_number":3021,"context_line":"                        self.detach_volume(context, bdm.volume_id, instance,"},{"line_number":3022,"context_line":"                                           destroy_bdm\u003dFalse)"},{"line_number":3023,"context_line":""},{"line_number":3024,"context_line":"            files \u003d self._decode_files(injected_files)"},{"line_number":3025,"context_line":""}],"source_content_type":"text/x-python","patch_set":1,"id":"7ad32947_80e4970d","line":3022,"in_reply_to":"bab921fb_e6bc646e","updated":"2015-04-27 16:45:42.000000000","message":"yes, it does. it\u0027s only driver.destroy() which is not called, if the instance is evacuated","commit_id":"2cfad889d8a335b85a319b39ebfb243744bae9ca"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"bfd8ae25627914f162d704252704dcfbf4138be3","unresolved":false,"context_lines":[{"line_number":4521,"context_line":"    @wrap_exception()"},{"line_number":4522,"context_line":"    @reverts_task_state"},{"line_number":4523,"context_line":"    @wrap_instance_fault"},{"line_number":4524,"context_line":"    def detach_volume(self, context, volume_id, instance, destroy_bdm\u003dTrue):"},{"line_number":4525,"context_line":"        \"\"\"Detach a volume from an instance."},{"line_number":4526,"context_line":""},{"line_number":4527,"context_line":"        :param context: security context"}],"source_content_type":"text/x-python","patch_set":5,"id":"7a016987_67591a35","line":4524,"updated":"2015-05-28 23:44:54.000000000","message":"To keep this consistent with the compute rpcapi method, we should probably pull the meat of this method into a private helper and then use that for the new kwarg.\n\nhttp://git.openstack.org/cgit/openstack/nova/tree/nova/compute/rpcapi.py#n415","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"e19d416b1c221fc108f7bb87532592133ef33e80","unresolved":false,"context_lines":[{"line_number":4521,"context_line":"    @wrap_exception()"},{"line_number":4522,"context_line":"    @reverts_task_state"},{"line_number":4523,"context_line":"    @wrap_instance_fault"},{"line_number":4524,"context_line":"    def detach_volume(self, context, volume_id, instance, destroy_bdm\u003dTrue):"},{"line_number":4525,"context_line":"        \"\"\"Detach a volume from an instance."},{"line_number":4526,"context_line":""},{"line_number":4527,"context_line":"        :param context: security context"}],"source_content_type":"text/x-python","patch_set":5,"id":"5afe65bd_881f8a6b","line":4524,"in_reply_to":"7a016987_67591a35","updated":"2015-06-06 05:57:10.000000000","message":"good point, will do!","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"9add9916b2f1f2c98983d19944bee840960fc895","unresolved":false,"context_lines":[{"line_number":4490,"context_line":"        :param instance: the Instance object to detach the volume from"},{"line_number":4491,"context_line":"        :param destroy_bdm: if True, the corresponding BDM entry will be marked"},{"line_number":4492,"context_line":"                            as deleted. Disabling this is useful for operations"},{"line_number":4493,"context_line":"                            like rebuild, when we don\u0027t want to recreate BDM"},{"line_number":4494,"context_line":""},{"line_number":4495,"context_line":"        \"\"\""},{"line_number":4496,"context_line":""}],"source_content_type":"text/x-python","patch_set":11,"id":"9a41bdd9_b4f77158","line":4493,"updated":"2015-07-17 19:52:49.000000000","message":"s/recreate/destroy/?","commit_id":"71f7d0cbb9913af4397688ccdcc89d80ba516804"}],"nova/tests/unit/compute/test_compute.py":[{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"53fa28f749058eff84ea51c4a5efe36aace9ca32","unresolved":false,"context_lines":[{"line_number":11179,"context_line":"        self._rebuild()"},{"line_number":11180,"context_line":""},{"line_number":11181,"context_line":"        # cleanup"},{"line_number":11182,"context_line":"        bdms \u003d db.block_device_mapping_get_all_by_instance(self.context,"},{"line_number":11183,"context_line":"                                                           self.inst.uuid)"},{"line_number":11184,"context_line":"        if not bdms:"},{"line_number":11185,"context_line":"            self.fail(\u0027BDM entry for the attached volume is missing\u0027)"},{"line_number":11186,"context_line":"        for bdm in bdms:"},{"line_number":11187,"context_line":"            db.block_device_mapping_destroy(self.context, bdm[\u0027id\u0027])"},{"line_number":11188,"context_line":""},{"line_number":11189,"context_line":"    def test_rebuild_on_host_with_shared_storage(self):"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a41bdd9_ba4a2eab","line":11186,"range":{"start_line":11182,"start_character":8,"end_line":11186,"end_character":24},"updated":"2015-07-17 00:10:58.000000000","message":"What are these changes for? They don\u0027t seem related to your patch","commit_id":"054eda8a1729361e6797b00fe45082e8e55545ff"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"184eb58f78506bc253f04064e0e9847dd20a5842","unresolved":false,"context_lines":[{"line_number":11183,"context_line":"                                                           self.inst.uuid)"},{"line_number":11184,"context_line":"        if not bdms:"},{"line_number":11185,"context_line":"            self.fail(\u0027BDM entry for the attached volume is missing\u0027)"},{"line_number":11186,"context_line":"        for bdm in bdms:"},{"line_number":11187,"context_line":"            db.block_device_mapping_destroy(self.context, bdm[\u0027id\u0027])"},{"line_number":11188,"context_line":""},{"line_number":11189,"context_line":"    def test_rebuild_on_host_with_shared_storage(self):"}],"source_content_type":"text/x-python","patch_set":10,"id":"9a41bdd9_870ed8e3","line":11186,"in_reply_to":"9a41bdd9_ba4a2eab","updated":"2015-07-17 13:02:35.000000000","message":"I added this when destroy_bdm was introduced. The point here is that I\u0027d expect this test to fail if BDMs were destroyed in advance on rebuild (which used to be the case before this patch), but it passed as this cleanup always succeeded, despite the fact we actually expected to see BDMs here.","commit_id":"054eda8a1729361e6797b00fe45082e8e55545ff"},{"author":{"_account_id":6873,"name":"Matt Riedemann","email":"mriedem.os@gmail.com","username":"mriedem"},"change_message_id":"2f7b701b3dd73bc5533d1b88ac51e3448f686619","unresolved":false,"context_lines":[{"line_number":2526,"context_line":"        self.compute.terminate_instance(self.context, instance, [], [])"},{"line_number":2527,"context_line":""},{"line_number":2528,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._detach_volume\u0027)"},{"line_number":2529,"context_line":"    def test_rebuild_driver_with_volumes(self, mock_detach):"},{"line_number":2530,"context_line":"        bdms \u003d block_device_obj.block_device_make_list(self.context,"},{"line_number":2531,"context_line":"                [fake_block_device.FakeDbBlockDeviceDict({"},{"line_number":2532,"context_line":"                \u0027id\u0027: 3,"}],"source_content_type":"text/x-python","patch_set":12,"id":"9a41bdd9_8f2fb8a0","line":2529,"updated":"2015-07-17 20:19:24.000000000","message":"FTR, I\u0027d prefer that this lived in test_compute_mgr (which is a NoDBTestCase) and used mock, but I see that this was an easy copy of the previous test + the volume stuff, so it\u0027s fine - and rebuild with attached volumes is totally busted without these changes so I\u0027d like to see them get in ASAP so we can backport to stable and get the Tempest coverage passing.","commit_id":"25f15b0bc3bd1971fd29062a7a001f8007485636"}],"nova/tests/unit/compute/test_compute_mgr.py":[{"author":{"_account_id":6062,"name":"jichenjc","email":"jichenjc@cn.ibm.com","username":"jichenjc"},"change_message_id":"7141ec77b2c0356cfc9fa84f5157ad3f0379b912","unresolved":false,"context_lines":[{"line_number":1811,"context_line":""},{"line_number":1812,"context_line":"        with mock.patch.object(self.compute, \u0027volume_api\u0027) as volume_api:"},{"line_number":1813,"context_line":"            with mock.patch.object(self.compute, \u0027driver\u0027) as driver:"},{"line_number":1814,"context_line":"                with mock.patch.object(self.compute, \u0027conductor_api\u0027) as cond:"},{"line_number":1815,"context_line":"                    self.compute.detach_volume(self.context, volume_id,"},{"line_number":1816,"context_line":"                                               inst_obj,"},{"line_number":1817,"context_line":"                                               destroy_bdm\u003ddestroy_bdm)"}],"source_content_type":"text/x-python","patch_set":1,"id":"bab921fb_a6d1cccf","line":1814,"updated":"2015-04-23 16:36:20.000000000","message":"I think we don\u0027t target for the vol_usage_update\ntest,so can we mock the function directly as wrapper if \nit has db access , then we can avoid the mock here?","commit_id":"2cfad889d8a335b85a319b39ebfb243744bae9ca"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"72321b0c1201b083d47110ccb4d514146e158c94","unresolved":false,"context_lines":[{"line_number":1811,"context_line":""},{"line_number":1812,"context_line":"        with mock.patch.object(self.compute, \u0027volume_api\u0027) as volume_api:"},{"line_number":1813,"context_line":"            with mock.patch.object(self.compute, \u0027driver\u0027) as driver:"},{"line_number":1814,"context_line":"                with mock.patch.object(self.compute, \u0027conductor_api\u0027) as cond:"},{"line_number":1815,"context_line":"                    self.compute.detach_volume(self.context, volume_id,"},{"line_number":1816,"context_line":"                                               inst_obj,"},{"line_number":1817,"context_line":"                                               destroy_bdm\u003ddestroy_bdm)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3acd31a7_8302683d","line":1814,"in_reply_to":"bab921fb_a6d1cccf","updated":"2015-04-29 19:54:36.000000000","message":"Done","commit_id":"2cfad889d8a335b85a319b39ebfb243744bae9ca"},{"author":{"_account_id":6062,"name":"jichenjc","email":"jichenjc@cn.ibm.com","username":"jichenjc"},"change_message_id":"7141ec77b2c0356cfc9fa84f5157ad3f0379b912","unresolved":false,"context_lines":[{"line_number":1823,"context_line":"                        cond.vol_usage_update.assert_called_once_with("},{"line_number":1824,"context_line":"                            self.context, volume_id, mock.ANY, mock.ANY,"},{"line_number":1825,"context_line":"                            mock.ANY, mock.ANY, inst_obj, update_totals\u003dTrue"},{"line_number":1826,"context_line":"                        )"},{"line_number":1827,"context_line":""},{"line_number":1828,"context_line":"                    detach.assert_called_once_with(self.context, inst_obj, bdm)"},{"line_number":1829,"context_line":"                    driver.get_volume_connector.return_value \u003d ("}],"source_content_type":"text/x-python","patch_set":1,"id":"bab921fb_6603b443","line":1826,"updated":"2015-04-23 16:36:20.000000000","message":"I think the code don\u0027t aim to test this function is called or not","commit_id":"2cfad889d8a335b85a319b39ebfb243744bae9ca"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"72321b0c1201b083d47110ccb4d514146e158c94","unresolved":false,"context_lines":[{"line_number":1823,"context_line":"                        cond.vol_usage_update.assert_called_once_with("},{"line_number":1824,"context_line":"                            self.context, volume_id, mock.ANY, mock.ANY,"},{"line_number":1825,"context_line":"                            mock.ANY, mock.ANY, inst_obj, update_totals\u003dTrue"},{"line_number":1826,"context_line":"                        )"},{"line_number":1827,"context_line":""},{"line_number":1828,"context_line":"                    detach.assert_called_once_with(self.context, inst_obj, bdm)"},{"line_number":1829,"context_line":"                    driver.get_volume_connector.return_value \u003d ("}],"source_content_type":"text/x-python","patch_set":1,"id":"3acd31a7_a371e4e2","line":1826,"in_reply_to":"bab921fb_6603b443","updated":"2015-04-29 19:54:36.000000000","message":"Done","commit_id":"2cfad889d8a335b85a319b39ebfb243744bae9ca"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"358799611b8517965a072d1fcc875ed0a1492b5f","unresolved":false,"context_lines":[{"line_number":1867,"context_line":""},{"line_number":1868,"context_line":"    @mock.patch(\u0027nova.objects.BlockDeviceMapping.get_by_volume_id\u0027)"},{"line_number":1869,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._detach_volume\u0027)"},{"line_number":1870,"context_line":"    @mock.patch(\u0027nova.compute.manager.compute_utils\u0027)"},{"line_number":1871,"context_line":"    @mock.patch(\u0027nova.conductor.manager.ConductorManager.vol_usage_update\u0027)"},{"line_number":1872,"context_line":"    def _test_detach_volume(self, vol_usage_update, utils, detach, bdm_get,"},{"line_number":1873,"context_line":"                            destroy_bdm\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":2,"id":"3acd31a7_d9768fd6","line":1870,"updated":"2015-05-05 00:39:02.000000000","message":"Why are you mocking this? I don\u0027t see it used in detach_volume","commit_id":"102185f5c8a5c79fb19ff51e808187d10a4e196f"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"5a85adb98c7ea3c61eb6fdc776f88fa0eb8ab9f0","unresolved":false,"context_lines":[{"line_number":1867,"context_line":""},{"line_number":1868,"context_line":"    @mock.patch(\u0027nova.objects.BlockDeviceMapping.get_by_volume_id\u0027)"},{"line_number":1869,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._detach_volume\u0027)"},{"line_number":1870,"context_line":"    @mock.patch(\u0027nova.compute.manager.compute_utils\u0027)"},{"line_number":1871,"context_line":"    @mock.patch(\u0027nova.conductor.manager.ConductorManager.vol_usage_update\u0027)"},{"line_number":1872,"context_line":"    def _test_detach_volume(self, vol_usage_update, utils, detach, bdm_get,"},{"line_number":1873,"context_line":"                            destroy_bdm\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":2,"id":"3acd31a7_f18eedce","line":1870,"in_reply_to":"3acd31a7_d9768fd6","updated":"2015-05-05 15:05:33.000000000","message":"good point. mocked _notify_about_instance_usage() instead","commit_id":"102185f5c8a5c79fb19ff51e808187d10a4e196f"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"358799611b8517965a072d1fcc875ed0a1492b5f","unresolved":false,"context_lines":[{"line_number":1889,"context_line":"                )"},{"line_number":1890,"context_line":"                driver.get_volume_connector.assert_called_once_with(inst_obj)"},{"line_number":1891,"context_line":"                volume_api.terminate_connection(self.context, volume_id,"},{"line_number":1892,"context_line":"                                                mock.sentinel.connector)"},{"line_number":1893,"context_line":"                volume_api.detach.assert_called_once_with(mock.ANY, volume_id)"},{"line_number":1894,"context_line":""},{"line_number":1895,"context_line":"                if destroy_bdm:"}],"source_content_type":"text/x-python","patch_set":2,"id":"3acd31a7_eb129256","line":1892,"updated":"2015-05-05 00:39:02.000000000","message":"I think you meant to do an assert_called_once_with here instead of a call?","commit_id":"102185f5c8a5c79fb19ff51e808187d10a4e196f"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"5a85adb98c7ea3c61eb6fdc776f88fa0eb8ab9f0","unresolved":false,"context_lines":[{"line_number":1889,"context_line":"                )"},{"line_number":1890,"context_line":"                driver.get_volume_connector.assert_called_once_with(inst_obj)"},{"line_number":1891,"context_line":"                volume_api.terminate_connection(self.context, volume_id,"},{"line_number":1892,"context_line":"                                                mock.sentinel.connector)"},{"line_number":1893,"context_line":"                volume_api.detach.assert_called_once_with(mock.ANY, volume_id)"},{"line_number":1894,"context_line":""},{"line_number":1895,"context_line":"                if destroy_bdm:"}],"source_content_type":"text/x-python","patch_set":2,"id":"3acd31a7_36dd7b6f","line":1892,"in_reply_to":"3acd31a7_eb129256","updated":"2015-05-05 15:05:33.000000000","message":"good catch!","commit_id":"102185f5c8a5c79fb19ff51e808187d10a4e196f"},{"author":{"_account_id":6062,"name":"jichenjc","email":"jichenjc@cn.ibm.com","username":"jichenjc"},"change_message_id":"5996f7345e27e101085b869ac4f27e08df63919f","unresolved":false,"context_lines":[{"line_number":1870,"context_line":""},{"line_number":1871,"context_line":"    @mock.patch(\u0027nova.objects.BlockDeviceMapping.get_by_volume_id\u0027)"},{"line_number":1872,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._detach_volume\u0027)"},{"line_number":1873,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._notify_about_instance_usage\u0027)  # noqa"},{"line_number":1874,"context_line":"    @mock.patch(\u0027nova.conductor.manager.ConductorManager.vol_usage_update\u0027)"},{"line_number":1875,"context_line":"    def _test_detach_volume(self, vol_usage_update, notify_inst_usage, detach,"},{"line_number":1876,"context_line":"                            bdm_get, destroy_bdm\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aca2d91_d33ff523","line":1873,"updated":"2015-05-06 15:42:08.000000000","message":"why #noqa ? \nis it too long? \ntry this please\n\n414     @mock.patch(\u0027nova.compute.manager.ComputeManager.\u0027\n 415                 \u0027_do_build_and_run_instance\u0027)","commit_id":"d9000f97c759098076a78c6120b2611914d6db0a"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"f4cceb1ba8ffe817a5ccd1c720e02874ffff6eae","unresolved":false,"context_lines":[{"line_number":1870,"context_line":""},{"line_number":1871,"context_line":"    @mock.patch(\u0027nova.objects.BlockDeviceMapping.get_by_volume_id\u0027)"},{"line_number":1872,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._detach_volume\u0027)"},{"line_number":1873,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._notify_about_instance_usage\u0027)  # noqa"},{"line_number":1874,"context_line":"    @mock.patch(\u0027nova.conductor.manager.ConductorManager.vol_usage_update\u0027)"},{"line_number":1875,"context_line":"    def _test_detach_volume(self, vol_usage_update, notify_inst_usage, detach,"},{"line_number":1876,"context_line":"                            bdm_get, destroy_bdm\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aca2d91_ea5b0653","line":1873,"in_reply_to":"1aca2d91_d33ff523","updated":"2015-05-06 22:02:03.000000000","message":"s/_do_build_and_run_instance/_notify_about_instance_usage\n\nYes, please don\u0027t add #noqa to make a line longer. Parentheses provide line continuation, you can use in most situations","commit_id":"d9000f97c759098076a78c6120b2611914d6db0a"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"e7a39ddbdc8da4ece9fb77ec343adfd7b04cc83f","unresolved":false,"context_lines":[{"line_number":1870,"context_line":""},{"line_number":1871,"context_line":"    @mock.patch(\u0027nova.objects.BlockDeviceMapping.get_by_volume_id\u0027)"},{"line_number":1872,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._detach_volume\u0027)"},{"line_number":1873,"context_line":"    @mock.patch(\u0027nova.compute.manager.ComputeManager._notify_about_instance_usage\u0027)  # noqa"},{"line_number":1874,"context_line":"    @mock.patch(\u0027nova.conductor.manager.ConductorManager.vol_usage_update\u0027)"},{"line_number":1875,"context_line":"    def _test_detach_volume(self, vol_usage_update, notify_inst_usage, detach,"},{"line_number":1876,"context_line":"                            bdm_get, destroy_bdm\u003dTrue):"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aca2d91_f7b99d2f","line":1873,"in_reply_to":"1aca2d91_ea5b0653","updated":"2015-05-07 09:42:53.000000000","message":"They do, but in this specific case of mock.patch() call it looks kind of ugly, IMHO.\n\nThat being said, I\u0027m not insisting on keeping #noqa here. Done.","commit_id":"d9000f97c759098076a78c6120b2611914d6db0a"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"f4cceb1ba8ffe817a5ccd1c720e02874ffff6eae","unresolved":false,"context_lines":[{"line_number":1895,"context_line":"                driver.get_volume_connector.assert_called_once_with(inst_obj)"},{"line_number":1896,"context_line":"                volume_api.terminate_connection.assert_called_once_with("},{"line_number":1897,"context_line":"                    self.context, volume_id, mock.sentinel.connector)"},{"line_number":1898,"context_line":"                volume_api.detach.assert_called_once_with(mock.ANY, volume_id)"},{"line_number":1899,"context_line":"                notify_inst_usage.assert_called_once_with("},{"line_number":1900,"context_line":"                    self.context, inst_obj, \"volume.detach\","},{"line_number":1901,"context_line":"                    extra_usage_info\u003d{\u0027volume_id\u0027: volume_id}"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aca2d91_4509cd2b","line":1898,"updated":"2015-05-06 22:02:03.000000000","message":"I didn\u0027t notice this before, but I think instead of using wildcard mock.ANY you can use self.context.elevated()","commit_id":"d9000f97c759098076a78c6120b2611914d6db0a"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"e7a39ddbdc8da4ece9fb77ec343adfd7b04cc83f","unresolved":false,"context_lines":[{"line_number":1895,"context_line":"                driver.get_volume_connector.assert_called_once_with(inst_obj)"},{"line_number":1896,"context_line":"                volume_api.terminate_connection.assert_called_once_with("},{"line_number":1897,"context_line":"                    self.context, volume_id, mock.sentinel.connector)"},{"line_number":1898,"context_line":"                volume_api.detach.assert_called_once_with(mock.ANY, volume_id)"},{"line_number":1899,"context_line":"                notify_inst_usage.assert_called_once_with("},{"line_number":1900,"context_line":"                    self.context, inst_obj, \"volume.detach\","},{"line_number":1901,"context_line":"                    extra_usage_info\u003d{\u0027volume_id\u0027: volume_id}"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aca2d91_57f851e5","line":1898,"in_reply_to":"1aca2d91_4509cd2b","updated":"2015-05-07 09:42:53.000000000","message":"Unfortunately, no. Context  instances will be compared by identity, not by value:\n\n    AssertionError: Expected call: detach(\u003cnova.context.RequestContext object at 0x7f0c9b46b650\u003e, \u0027123\u0027)\n    Actual call: detach(\u003cnova.context.RequestContext object at 0x7f0c9b464350\u003e, \u0027123\u0027)\n\n\nLooks like Context.elevated() always produce a new Context instance. I\u0027m not sure it\u0027s worth it to mock elevated() too.","commit_id":"d9000f97c759098076a78c6120b2611914d6db0a"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"4d32ac0363cde912375147dde798d0a8d6d6a505","unresolved":false,"context_lines":[{"line_number":1895,"context_line":"                driver.get_volume_connector.assert_called_once_with(inst_obj)"},{"line_number":1896,"context_line":"                volume_api.terminate_connection.assert_called_once_with("},{"line_number":1897,"context_line":"                    self.context, volume_id, mock.sentinel.connector)"},{"line_number":1898,"context_line":"                volume_api.detach.assert_called_once_with(mock.ANY, volume_id)"},{"line_number":1899,"context_line":"                notify_inst_usage.assert_called_once_with("},{"line_number":1900,"context_line":"                    self.context, inst_obj, \"volume.detach\","},{"line_number":1901,"context_line":"                    extra_usage_info\u003d{\u0027volume_id\u0027: volume_id}"}],"source_content_type":"text/x-python","patch_set":3,"id":"1aca2d91_394ed06f","line":1898,"in_reply_to":"1aca2d91_57f851e5","updated":"2015-05-07 19:10:46.000000000","message":"Ah, should have realized. I saw the \"self.context\" in the other asserts and didn\u0027t think of it.","commit_id":"d9000f97c759098076a78c6120b2611914d6db0a"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"4971acbb698af2b1253353fd20102c9c5fff85f3","unresolved":false,"context_lines":[{"line_number":1832,"context_line":"        volume_id \u003d \u0027123\u0027"},{"line_number":1833,"context_line":"        inst_obj \u003d mock.sentinel.inst_obj"},{"line_number":1834,"context_line":""},{"line_number":1835,"context_line":"        bdm \u003d mock.MagicMock()"},{"line_number":1836,"context_line":"        bdm.device_name \u003d \u0027vdb\u0027"},{"line_number":1837,"context_line":"        bdm_get.return_value \u003d bdm"},{"line_number":1838,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"7a016987_2c8b0cc5","line":1835,"updated":"2015-05-28 23:13:46.000000000","message":"I think this mock should have a spec, for example:\n\n bdm \u003d mock.Mock(spec\u003dobjects.BlockDeviceMapping)\n\notherwise, any method call on a MagicMock will succeed whether it exists or not","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"e19d416b1c221fc108f7bb87532592133ef33e80","unresolved":false,"context_lines":[{"line_number":1832,"context_line":"        volume_id \u003d \u0027123\u0027"},{"line_number":1833,"context_line":"        inst_obj \u003d mock.sentinel.inst_obj"},{"line_number":1834,"context_line":""},{"line_number":1835,"context_line":"        bdm \u003d mock.MagicMock()"},{"line_number":1836,"context_line":"        bdm.device_name \u003d \u0027vdb\u0027"},{"line_number":1837,"context_line":"        bdm_get.return_value \u003d bdm"},{"line_number":1838,"context_line":""}],"source_content_type":"text/x-python","patch_set":5,"id":"5afe65bd_4328549a","line":1835,"in_reply_to":"7a016987_2c8b0cc5","updated":"2015-06-06 05:57:10.000000000","message":"Agreed, otherwise mock allows way too much. Didn\u0027t know about this feature of mock. Thanks! ;)","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"4971acbb698af2b1253353fd20102c9c5fff85f3","unresolved":false,"context_lines":[{"line_number":1837,"context_line":"        bdm_get.return_value \u003d bdm"},{"line_number":1838,"context_line":""},{"line_number":1839,"context_line":"        with mock.patch.object(self.compute, \u0027volume_api\u0027) as volume_api:"},{"line_number":1840,"context_line":"            with mock.patch.object(self.compute, \u0027driver\u0027) as driver:"},{"line_number":1841,"context_line":"                driver.get_volume_connector.return_value \u003d ("},{"line_number":1842,"context_line":"                    mock.sentinel.connector"},{"line_number":1843,"context_line":"                )"}],"source_content_type":"text/x-python","patch_set":5,"id":"7a016987_02aff72a","line":1840,"updated":"2015-05-28 23:13:46.000000000","message":"Information: We try to avoid the nested context managers and instead decorate a nested function -- that way the indenting doesn\u0027t go unnecessarily deep","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"e19d416b1c221fc108f7bb87532592133ef33e80","unresolved":false,"context_lines":[{"line_number":1837,"context_line":"        bdm_get.return_value \u003d bdm"},{"line_number":1838,"context_line":""},{"line_number":1839,"context_line":"        with mock.patch.object(self.compute, \u0027volume_api\u0027) as volume_api:"},{"line_number":1840,"context_line":"            with mock.patch.object(self.compute, \u0027driver\u0027) as driver:"},{"line_number":1841,"context_line":"                driver.get_volume_connector.return_value \u003d ("},{"line_number":1842,"context_line":"                    mock.sentinel.connector"},{"line_number":1843,"context_line":"                )"}],"source_content_type":"text/x-python","patch_set":5,"id":"5afe65bd_86809af8","line":1840,"in_reply_to":"7a016987_02aff72a","updated":"2015-06-06 05:57:10.000000000","message":"Generally, I prefer @ mocking style too, but in this particular case we need to mock instance methods (as we don\u0027t know which particular driver class will be instantiated).","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"4971acbb698af2b1253353fd20102c9c5fff85f3","unresolved":false,"context_lines":[{"line_number":1839,"context_line":"        with mock.patch.object(self.compute, \u0027volume_api\u0027) as volume_api:"},{"line_number":1840,"context_line":"            with mock.patch.object(self.compute, \u0027driver\u0027) as driver:"},{"line_number":1841,"context_line":"                driver.get_volume_connector.return_value \u003d ("},{"line_number":1842,"context_line":"                    mock.sentinel.connector"},{"line_number":1843,"context_line":"                )"},{"line_number":1844,"context_line":""},{"line_number":1845,"context_line":"                self.compute.detach_volume(self.context, volume_id,"}],"source_content_type":"text/x-python","patch_set":5,"id":"7a016987_c27b1fbd","line":1842,"updated":"2015-05-28 23:13:46.000000000","message":"I suggest declaring a variable for this, same as you did on L1833, then you can avoid the line length problem and also reuse it on L1852.","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"},{"author":{"_account_id":6849,"name":"Roman Podoliaka","email":"roman.podoliaka@gmail.com","username":"rpodolyaka"},"change_message_id":"e19d416b1c221fc108f7bb87532592133ef33e80","unresolved":false,"context_lines":[{"line_number":1839,"context_line":"        with mock.patch.object(self.compute, \u0027volume_api\u0027) as volume_api:"},{"line_number":1840,"context_line":"            with mock.patch.object(self.compute, \u0027driver\u0027) as driver:"},{"line_number":1841,"context_line":"                driver.get_volume_connector.return_value \u003d ("},{"line_number":1842,"context_line":"                    mock.sentinel.connector"},{"line_number":1843,"context_line":"                )"},{"line_number":1844,"context_line":""},{"line_number":1845,"context_line":"                self.compute.detach_volume(self.context, volume_id,"}],"source_content_type":"text/x-python","patch_set":5,"id":"5afe65bd_66291e37","line":1842,"in_reply_to":"7a016987_c27b1fbd","updated":"2015-06-06 05:57:10.000000000","message":"Done.","commit_id":"c385e1b6ce8764b08b775e131176db405be0850c"}]}
