)]}'
{"nova/tests/unit/virt/test_driver.py":[{"author":{"_account_id":11303,"name":"Markus Zoeller (markus_z)","email":"mzoeller@linux.vnet.ibm.com","username":"mzoeller"},"change_message_id":"fd793ed0ca6ad5c21d55ebfc4703d6bbf8c9c7da","unresolved":false,"context_lines":[{"line_number":109,"context_line":"        #     KeyError,"},{"line_number":110,"context_line":"        #     lambda: failures[fail3]"},{"line_number":111,"context_line":"        # )"},{"line_number":112,"context_line":""},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"class DriverMethodTestCase(test.NoDBTestCase):"},{"line_number":115,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_f4dd4871","line":112,"updated":"2016-11-08 09:24:19.000000000","message":"As we want to ensure that an Exception during the driver import doesn\u0027t stop the creation of the driver_registry, I think I would go with something like this (pseudo-code):\n\n    @mock.patch(\"oslo_utils.importutils.import_class\")\n    def test_driver_dict_from_config_exception(self, mocked_import_class):\n        mocked_import_class.side_effect(ValueError)\n        registry \u003d driver.driver_dict_from_config([\n            \u0027key1\u003dthis.driver.import.will.fail\u0027,\n        ])\n        self.assertEqual({}, registry)","commit_id":"41d57d891038e09237d397022510d5322b50afd7"},{"author":{"_account_id":11303,"name":"Markus Zoeller (markus_z)","email":"mzoeller@linux.vnet.ibm.com","username":"mzoeller"},"change_message_id":"ac6a2561a942f115d1dbaa86b948fe0097de8a73","unresolved":false,"context_lines":[{"line_number":109,"context_line":"        #     KeyError,"},{"line_number":110,"context_line":"        #     lambda: failures[fail3]"},{"line_number":111,"context_line":"        # )"},{"line_number":112,"context_line":""},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"class DriverMethodTestCase(test.NoDBTestCase):"},{"line_number":115,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_1d6d7898","line":112,"in_reply_to":"9a629dbe_5a7ffba9","updated":"2016-11-08 11:49:49.000000000","message":"@sahid: Ah, sorry, I didn\u0027t see that.","commit_id":"41d57d891038e09237d397022510d5322b50afd7"},{"author":{"_account_id":7730,"name":"Sahid Orentino Ferdjaoui","email":"sahid.ferdjaoui@industrialdiscipline.com","username":"sahid"},"change_message_id":"b8f0e5701608deabdecb4e538ea485e917b390de","unresolved":false,"context_lines":[{"line_number":109,"context_line":"        #     KeyError,"},{"line_number":110,"context_line":"        #     lambda: failures[fail3]"},{"line_number":111,"context_line":"        # )"},{"line_number":112,"context_line":""},{"line_number":113,"context_line":""},{"line_number":114,"context_line":"class DriverMethodTestCase(test.NoDBTestCase):"},{"line_number":115,"context_line":""}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_5a7ffba9","line":112,"in_reply_to":"9a629dbe_f4dd4871","updated":"2016-11-08 10:03:20.000000000","message":"Yep It\u0027s exactly what I have suggested in my previous comment.","commit_id":"41d57d891038e09237d397022510d5322b50afd7"}],"nova/virt/driver.py":[{"author":{"_account_id":7730,"name":"Sahid Orentino Ferdjaoui","email":"sahid.ferdjaoui@industrialdiscipline.com","username":"sahid"},"change_message_id":"a49295a53ed3ea62083fb7592ff9eb12c49a31dc","unresolved":false,"context_lines":[{"line_number":40,"context_line":""},{"line_number":41,"context_line":"    for driver_str in named_driver_config:"},{"line_number":42,"context_line":"        driver_type, _sep, driver \u003d driver_str.partition(\u0027\u003d\u0027)"},{"line_number":43,"context_line":"        driver_class \u003d importutils.import_class(driver)"},{"line_number":44,"context_line":"        driver_registry[driver_type] \u003d driver_class(*args, **kwargs)"},{"line_number":45,"context_line":""},{"line_number":46,"context_line":"    return driver_registry"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a629dbe_d8e89719","side":"PARENT","line":43,"updated":"2016-11-07 15:46:22.000000000","message":"I would say for your unittest, what you need to do is to mock import_call to return a MagicMock. That MagicMock has been prepared to raise an exception ValueError when called.\n\nIs that possible ?","commit_id":"0132cc8c2663843a891e054d9185e6ba2fd589ad"},{"author":{"_account_id":7730,"name":"Sahid Orentino Ferdjaoui","email":"sahid.ferdjaoui@industrialdiscipline.com","username":"sahid"},"change_message_id":"8d197193befda1dbd42ae8515ae665190f014e7a","unresolved":false,"context_lines":[{"line_number":43,"context_line":"        driver_class \u003d importutils.import_class(driver)"},{"line_number":44,"context_line":"        try:"},{"line_number":45,"context_line":"            driver_registry[driver_type] \u003d driver_class(*args, **kwargs)"},{"line_number":46,"context_line":"        # Would preferably catch \u0027InvalidConnectorProtocol\u0027 exception"},{"line_number":47,"context_line":"        except ValueError:"},{"line_number":48,"context_line":"            LOG.info(_LI(\"Driver \u0027%(driver_type)s\u0027 not supported\"),"},{"line_number":49,"context_line":"                     {\u0027driver_type\u0027: driver_type})"}],"source_content_type":"text/x-python","patch_set":1,"id":"9a629dbe_8ff180d0","line":46,"updated":"2016-11-07 13:29:59.000000000","message":"Please add TODO tag here, to change for InvalidConnectorProtocol when available","commit_id":"93ee314a2d822406f26e1d46763baf092c1491c4"},{"author":{"_account_id":11303,"name":"Markus Zoeller (markus_z)","email":"mzoeller@linux.vnet.ibm.com","username":"mzoeller"},"change_message_id":"fd793ed0ca6ad5c21d55ebfc4703d6bbf8c9c7da","unresolved":false,"context_lines":[{"line_number":44,"context_line":"        try:"},{"line_number":45,"context_line":"            driver_registry[driver_type] \u003d driver_class(*args, **kwargs)"},{"line_number":46,"context_line":"        # TODO(arne_r) Would preferably catch \u0027InvalidConnectorProtocol\u0027"},{"line_number":47,"context_line":"        except ValueError:"},{"line_number":48,"context_line":"            LOG.info(_LI(\"Driver \u0027%(driver_type)s\u0027 not supported or \""},{"line_number":49,"context_line":"                         \"\u0027%(driver)s\u0027 could not be found.\"),"},{"line_number":50,"context_line":"                     {\u0027driver_type\u0027: driver_type, \u0027driver\u0027: driver})"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_b40f50e0","line":47,"range":{"start_line":47,"start_character":15,"end_line":47,"end_character":25},"updated":"2016-11-08 09:24:19.000000000","message":"Assumed the os-brick library will throw the \"InvalidConnectorProtocol\" in a newer version, we will get broken again. I think I would add the expected exception here right from the start:\n\n    except (ValueError, InvalidConnectorProtocol) as e:\n\nAnd when the new version of os-brick is in place, we can drop the then obsolete ValueError (or keep it in case other platforms run into that too).","commit_id":"41d57d891038e09237d397022510d5322b50afd7"},{"author":{"_account_id":19991,"name":"Arne Recknagel","email":"arne.recknagel@hotmail.com","username":"arecknag"},"change_message_id":"7ebbf5fa2c839fa13b0ae02a0005792d5b17dcc6","unresolved":false,"context_lines":[{"line_number":44,"context_line":"        try:"},{"line_number":45,"context_line":"            driver_registry[driver_type] \u003d driver_class(*args, **kwargs)"},{"line_number":46,"context_line":"        # TODO(arne_r) Would preferably catch \u0027InvalidConnectorProtocol\u0027"},{"line_number":47,"context_line":"        except ValueError:"},{"line_number":48,"context_line":"            LOG.info(_LI(\"Driver \u0027%(driver_type)s\u0027 not supported or \""},{"line_number":49,"context_line":"                         \"\u0027%(driver)s\u0027 could not be found.\"),"},{"line_number":50,"context_line":"                     {\u0027driver_type\u0027: driver_type, \u0027driver\u0027: driver})"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_ff952140","line":47,"range":{"start_line":47,"start_character":15,"end_line":47,"end_character":25},"in_reply_to":"9a629dbe_b40f50e0","updated":"2016-11-08 09:58:52.000000000","message":"How do I import it without creating an error?\n\n    InvalidConnectorProtocol \u003d importutils.import_class(\u0027os_brick.exception.InvalidConnectorProtocol\u0027)\n\nDoes this work?","commit_id":"41d57d891038e09237d397022510d5322b50afd7"},{"author":{"_account_id":11303,"name":"Markus Zoeller (markus_z)","email":"mzoeller@linux.vnet.ibm.com","username":"mzoeller"},"change_message_id":"ac6a2561a942f115d1dbaa86b948fe0097de8a73","unresolved":false,"context_lines":[{"line_number":44,"context_line":"        try:"},{"line_number":45,"context_line":"            driver_registry[driver_type] \u003d driver_class(*args, **kwargs)"},{"line_number":46,"context_line":"        # TODO(arne_r) Would preferably catch \u0027InvalidConnectorProtocol\u0027"},{"line_number":47,"context_line":"        except ValueError:"},{"line_number":48,"context_line":"            LOG.info(_LI(\"Driver \u0027%(driver_type)s\u0027 not supported or \""},{"line_number":49,"context_line":"                         \"\u0027%(driver)s\u0027 could not be found.\"),"},{"line_number":50,"context_line":"                     {\u0027driver_type\u0027: driver_type, \u0027driver\u0027: driver})"}],"source_content_type":"text/x-python","patch_set":3,"id":"9a629dbe_fd928456","line":47,"range":{"start_line":47,"start_character":15,"end_line":47,"end_character":25},"in_reply_to":"9a629dbe_ff952140","updated":"2016-11-08 11:49:49.000000000","message":"Probably something like this:\n\n    from os_brick import exception as os_brick_exception\n\nSomething similar is done here: \n\nhttps://github.com/openstack/nova/blob/36322fdf48dc50a4518c0c9fd6aa787d3aa01fed/nova/tests/unit/virt/libvirt/volume/test_iscsi.py#L75-L77","commit_id":"41d57d891038e09237d397022510d5322b50afd7"}]}
