)]}'
{"nova/tests/unit/virt/powervm/test_media.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c6415490ea313be9499ba614a066320d11a038cc","unresolved":false,"context_lines":[{"line_number":112,"context_line":"        mock_upl.assert_called_once_with(self.apt, \u0027vios_uuid\u0027, mock.ANY,"},{"line_number":113,"context_line":"                                         expected_file_name,"},{"line_number":114,"context_line":"                                         mock_getsize.return_value)"},{"line_number":115,"context_line":"        wtsk.add_functor_subtask.assert_called_once()"},{"line_number":116,"context_line":""},{"line_number":117,"context_line":"    def test_sanitize_network_info(self):"},{"line_number":118,"context_line":"        network_info \u003d [{\u0027type\u0027: \u0027lbr\u0027}, {\u0027type\u0027: \u0027pvm_sea\u0027},"}],"source_content_type":"text/x-python","patch_set":5,"id":"3f79a3b5_77b534cf","line":115,"updated":"2018-10-16 19:54:24.000000000","message":"Mm, so we\u0027re letting NamedTemporaryFile actually run and create its temporary file, which is slightly icky (though I can\u0027t really tell you why I feel that way), and then using mock.ANY because we can\u0027t predict the file name, which is worse. The use of call_args[0][3] to getsize at least ensures we\u0027re passing the same thing around (though you should save that guy off and use it in the mock_upl assertion as well). But we should be able to do better.\n\nTwo ways around this, both involving mocking NamedTemporaryFile:\n\n1) Mock NamedTemporaryFile as a MagicMock so that its __enter__ and __exit__ methods get generated automatically. Then you can reference the context manager (equivalent to fh in the code) as the_mock.return_value.__enter__.return_value; and the file name as that guy\u0027s .name attribute.\n\n2) Mock NamedTemporaryFile as a regular mock and create an actual context manager to assign as its side_effect. Something like:\n\n # So we can assert call args with mock_fh and mock_fh.name\n mock_fh \u003d mock.Mock()\n\n @contextlib.contextmanager\n def mock_named_temporary_file(*a, **k):\n     yield mock_fh\n\n # mock_ntf is @mock.patch(\u0027tempfile.NamedTemporaryFile\u0027)\n mock_ntf.side_effect \u003d mock_named_temporary_file","commit_id":"5492eb5a0b80367a564e0b6a7653cb3278e395e4"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"ff8f96b741cd2949f1b2af1d2c747c0f64e17a82","unresolved":false,"context_lines":[{"line_number":26,"context_line":"from pypowervm.wrappers import network as pvm_net"},{"line_number":27,"context_line":"from pypowervm.wrappers import storage as pvm_stg"},{"line_number":28,"context_line":"from pypowervm.wrappers import virtual_io_server as pvm_vios"},{"line_number":29,"context_line":"import six"},{"line_number":30,"context_line":"if six.PY2:"},{"line_number":31,"context_line":"    import __builtin__ as builtins"},{"line_number":32,"context_line":"elif six.PY3:"},{"line_number":33,"context_line":"    import builtins"},{"line_number":34,"context_line":""},{"line_number":35,"context_line":"from nova import test"},{"line_number":36,"context_line":"from nova.virt.powervm import media as m"}],"source_content_type":"text/x-python","patch_set":6,"id":"3f79a3b5_be7956c7","line":33,"range":{"start_line":29,"start_character":0,"end_line":33,"end_character":19},"updated":"2018-10-17 13:27:14.000000000","message":"strike","commit_id":"665453a215d87a525e3e361ea02645515b8da86e"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"b258213abb1a103ea833fd862c8e5a29d51df56e","unresolved":false,"context_lines":[{"line_number":57,"context_line":"        iso_path \u003d \u0027/tmp/cfgdrv.iso\u0027"},{"line_number":58,"context_line":"        cfg_dr_builder._create_cfg_dr_iso(mock_instance, mock_files, mock_net,"},{"line_number":59,"context_line":"                                          iso_path)"},{"line_number":60,"context_line":"        self.assertTrue(mock_mkdrv.call_count, 1)"},{"line_number":61,"context_line":""},{"line_number":62,"context_line":"        # Test retry iso create"},{"line_number":63,"context_line":"        mock_mkdrv.reset_mock()"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_f1fca2b7","line":60,"range":{"start_line":60,"start_character":13,"end_line":60,"end_character":23},"updated":"2018-10-19 18:55:08.000000000","message":"I think you meant assertEqual here. The optional second arg for assertTrue is the message to emit if the assertion fails.","commit_id":"27da237edb55acf9f9f081873004f6fb7615d943"},{"author":{"_account_id":10608,"name":"Matthew Edmonds","email":"edmondsw@us.ibm.com","username":"edmondsw"},"change_message_id":"4cfaa8579b9505c30512eef95d5af461ede2e9af","unresolved":false,"context_lines":[{"line_number":57,"context_line":"        iso_path \u003d \u0027/tmp/cfgdrv.iso\u0027"},{"line_number":58,"context_line":"        cfg_dr_builder._create_cfg_dr_iso(mock_instance, mock_files, mock_net,"},{"line_number":59,"context_line":"                                          iso_path)"},{"line_number":60,"context_line":"        self.assertTrue(mock_mkdrv.call_count, 1)"},{"line_number":61,"context_line":""},{"line_number":62,"context_line":"        # Test retry iso create"},{"line_number":63,"context_line":"        mock_mkdrv.reset_mock()"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_9906b41b","line":60,"range":{"start_line":60,"start_character":13,"end_line":60,"end_character":23},"in_reply_to":"3f79a3b5_f1fca2b7","updated":"2018-10-22 13:27:31.000000000","message":"yep, good catch.","commit_id":"27da237edb55acf9f9f081873004f6fb7615d943"},{"author":{"_account_id":4690,"name":"melanie witt","display_name":"melwitt","email":"melwittt@gmail.com","username":"melwitt"},"change_message_id":"b258213abb1a103ea833fd862c8e5a29d51df56e","unresolved":false,"context_lines":[{"line_number":106,"context_line":"            mock_instance, \u0027files\u0027, \u0027netinfo\u0027, ftsk, admin_pass\u003d\u0027pass\u0027)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"        mock_ccdi.assert_called_once_with(mock_instance, \u0027files\u0027, \u0027netinfo\u0027,"},{"line_number":109,"context_line":"                                          \u0027iso_path\u0027, admin_pass\u003d\u0027pass\u0027)"},{"line_number":110,"context_line":"        mock_getsize.assert_called_once_with(\u0027iso_path\u0027)"},{"line_number":111,"context_line":"        mock_upl.assert_called_once_with(self.apt, \u0027vios_uuid\u0027, fh,"},{"line_number":112,"context_line":"                                         expected_file_name,"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_91a8ce8b","line":109,"updated":"2018-10-19 18:55:08.000000000","message":"Maybe worth asserting that mock_ntf was called with mode\u003d\u0027rb\u0027, similar to how mock_open was asserted previously?","commit_id":"27da237edb55acf9f9f081873004f6fb7615d943"},{"author":{"_account_id":10608,"name":"Matthew Edmonds","email":"edmondsw@us.ibm.com","username":"edmondsw"},"change_message_id":"4cfaa8579b9505c30512eef95d5af461ede2e9af","unresolved":false,"context_lines":[{"line_number":106,"context_line":"            mock_instance, \u0027files\u0027, \u0027netinfo\u0027, ftsk, admin_pass\u003d\u0027pass\u0027)"},{"line_number":107,"context_line":""},{"line_number":108,"context_line":"        mock_ccdi.assert_called_once_with(mock_instance, \u0027files\u0027, \u0027netinfo\u0027,"},{"line_number":109,"context_line":"                                          \u0027iso_path\u0027, admin_pass\u003d\u0027pass\u0027)"},{"line_number":110,"context_line":"        mock_getsize.assert_called_once_with(\u0027iso_path\u0027)"},{"line_number":111,"context_line":"        mock_upl.assert_called_once_with(self.apt, \u0027vios_uuid\u0027, fh,"},{"line_number":112,"context_line":"                                         expected_file_name,"}],"source_content_type":"text/x-python","patch_set":7,"id":"3f79a3b5_43cd74b8","line":109,"in_reply_to":"3f79a3b5_91a8ce8b","updated":"2018-10-22 13:27:31.000000000","message":"sure thing","commit_id":"27da237edb55acf9f9f081873004f6fb7615d943"}],"nova/virt/powervm/media.py":[{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fec44d76b2c173e630a10d06554593b2778573d8","unresolved":false,"context_lines":[{"line_number":154,"context_line":"        # our choice (meaningful and with a constrained length)"},{"line_number":155,"context_line":"        iso_dir \u003d tempfile.mkdtemp()"},{"line_number":156,"context_line":"        try:"},{"line_number":157,"context_line":"            file_name \u003d pvm_util.sanitize_file_name_for_api("},{"line_number":158,"context_line":"                instance.uuid, prefix\u003d\u0027cfg_\u0027, suffix\u003d\u0027.iso\u0027,"},{"line_number":159,"context_line":"                max_len\u003dpvm_const.MaxLen.VOPT_NAME)"},{"line_number":160,"context_line":"            iso_path \u003d os.path.join(iso_dir, file_name)"},{"line_number":161,"context_line":""},{"line_number":162,"context_line":"            self._create_cfg_dr_iso(instance, injected_files, network_info,"},{"line_number":163,"context_line":"                                    iso_path, admin_pass\u003dadmin_pass)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_2f7a4724","line":160,"range":{"start_line":157,"start_character":0,"end_line":160,"end_character":55},"updated":"2018-10-12 21:52:07.000000000","message":"Why did you move this?\n\nIt would be cleaner to have it where it was before, so you can keep the umask business with it.","commit_id":"8dd656f2d3bfb18c571a4fa5fec088c381f7e048"},{"author":{"_account_id":10608,"name":"Matthew Edmonds","email":"edmondsw@us.ibm.com","username":"edmondsw"},"change_message_id":"1a243d38a205164667edc6d3c50be62ac6a99166","unresolved":false,"context_lines":[{"line_number":154,"context_line":"        # our choice (meaningful and with a constrained length)"},{"line_number":155,"context_line":"        iso_dir \u003d tempfile.mkdtemp()"},{"line_number":156,"context_line":"        try:"},{"line_number":157,"context_line":"            file_name \u003d pvm_util.sanitize_file_name_for_api("},{"line_number":158,"context_line":"                instance.uuid, prefix\u003d\u0027cfg_\u0027, suffix\u003d\u0027.iso\u0027,"},{"line_number":159,"context_line":"                max_len\u003dpvm_const.MaxLen.VOPT_NAME)"},{"line_number":160,"context_line":"            iso_path \u003d os.path.join(iso_dir, file_name)"},{"line_number":161,"context_line":""},{"line_number":162,"context_line":"            self._create_cfg_dr_iso(instance, injected_files, network_info,"},{"line_number":163,"context_line":"                                    iso_path, admin_pass\u003dadmin_pass)"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_4470c5da","line":160,"range":{"start_line":157,"start_character":0,"end_line":160,"end_character":55},"in_reply_to":"3f79a3b5_2f7a4724","updated":"2018-10-13 03:14:32.000000000","message":"so that I wouldn\u0027t have to return them. But I can change it back if you prefer.","commit_id":"8dd656f2d3bfb18c571a4fa5fec088c381f7e048"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"fec44d76b2c173e630a10d06554593b2778573d8","unresolved":false,"context_lines":[{"line_number":163,"context_line":"                                    iso_path, admin_pass\u003dadmin_pass)"},{"line_number":164,"context_line":""},{"line_number":165,"context_line":"            # Upload the media"},{"line_number":166,"context_line":"            try:"},{"line_number":167,"context_line":"                with open(iso_path, \u0027rb\u0027) as d_stream:"},{"line_number":168,"context_line":"                    vopt, f_uuid \u003d tsk_stg.upload_vopt("},{"line_number":169,"context_line":"                        self.adapter, self.vios_uuid, d_stream, file_name,"},{"line_number":170,"context_line":"                        os.path.getsize(iso_path))"},{"line_number":171,"context_line":"            finally:"},{"line_number":172,"context_line":"                # The media can be removed now that the upload is complete"},{"line_number":173,"context_line":"                os.remove(iso_path)"},{"line_number":174,"context_line":"        finally:"},{"line_number":175,"context_line":"            # The temporary directory can now be removed"},{"line_number":176,"context_line":"            os.rmdir(iso_dir)"},{"line_number":177,"context_line":""},{"line_number":178,"context_line":"        # Define the function to build and add the mapping"},{"line_number":179,"context_line":"        def add_func(vios_w):"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_afb897e7","line":176,"range":{"start_line":166,"start_character":0,"end_line":176,"end_character":29},"updated":"2018-10-12 21:52:07.000000000","message":"could use shutil.rmtree instead and save the inner try/finally/remove","commit_id":"8dd656f2d3bfb18c571a4fa5fec088c381f7e048"},{"author":{"_account_id":10608,"name":"Matthew Edmonds","email":"edmondsw@us.ibm.com","username":"edmondsw"},"change_message_id":"1a243d38a205164667edc6d3c50be62ac6a99166","unresolved":false,"context_lines":[{"line_number":163,"context_line":"                                    iso_path, admin_pass\u003dadmin_pass)"},{"line_number":164,"context_line":""},{"line_number":165,"context_line":"            # Upload the media"},{"line_number":166,"context_line":"            try:"},{"line_number":167,"context_line":"                with open(iso_path, \u0027rb\u0027) as d_stream:"},{"line_number":168,"context_line":"                    vopt, f_uuid \u003d tsk_stg.upload_vopt("},{"line_number":169,"context_line":"                        self.adapter, self.vios_uuid, d_stream, file_name,"},{"line_number":170,"context_line":"                        os.path.getsize(iso_path))"},{"line_number":171,"context_line":"            finally:"},{"line_number":172,"context_line":"                # The media can be removed now that the upload is complete"},{"line_number":173,"context_line":"                os.remove(iso_path)"},{"line_number":174,"context_line":"        finally:"},{"line_number":175,"context_line":"            # The temporary directory can now be removed"},{"line_number":176,"context_line":"            os.rmdir(iso_dir)"},{"line_number":177,"context_line":""},{"line_number":178,"context_line":"        # Define the function to build and add the mapping"},{"line_number":179,"context_line":"        def add_func(vios_w):"}],"source_content_type":"text/x-python","patch_set":1,"id":"3f79a3b5_04764dd6","line":176,"range":{"start_line":166,"start_character":0,"end_line":176,"end_character":29},"in_reply_to":"3f79a3b5_afb897e7","updated":"2018-10-13 03:14:32.000000000","message":"good call","commit_id":"8dd656f2d3bfb18c571a4fa5fec088c381f7e048"},{"author":{"_account_id":10608,"name":"Matthew Edmonds","email":"edmondsw@us.ibm.com","username":"edmondsw"},"change_message_id":"4feb9eb52fd70494e5ee248324dbcaaa6d053659","unresolved":false,"context_lines":[{"line_number":170,"context_line":"            # Upload the media"},{"line_number":171,"context_line":"            with open(iso_path, \u0027rb\u0027) as d_stream:"},{"line_number":172,"context_line":"                vopt, f_uuid \u003d tsk_stg.upload_vopt("},{"line_number":173,"context_line":"                    self.adapter, self.vios_uuid, d_stream, file_name,"},{"line_number":174,"context_line":"                    os.path.getsize(iso_path))"},{"line_number":175,"context_line":"        finally:"},{"line_number":176,"context_line":"            # The temporary directory and iso can now be removed"}],"source_content_type":"text/x-python","patch_set":3,"id":"3f79a3b5_e8ae667e","line":173,"range":{"start_line":173,"start_character":60,"end_line":173,"end_character":69},"updated":"2018-10-15 20:21:46.000000000","message":"Could probably use mkstemp instead of mkdtemp and then rename the file here for the upload. Then we could avoid the umask change.","commit_id":"e034aa530381c32a044da776fc7d6ffd6204473a"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"b9509b34b4bbd5dd6d0f9edeb6eddf9fda127a45","unresolved":false,"context_lines":[{"line_number":151,"context_line":"            max_len\u003dpvm_const.MaxLen.VOPT_NAME)"},{"line_number":152,"context_line":""},{"line_number":153,"context_line":"        # Create and upload the media"},{"line_number":154,"context_line":"        iso_path \u003d tempfile.mkstemp()[1]"},{"line_number":155,"context_line":"        try:"},{"line_number":156,"context_line":"            self._create_cfg_dr_iso(instance, injected_files, network_info,"},{"line_number":157,"context_line":"                                    iso_path, admin_pass\u003dadmin_pass)"}],"source_content_type":"text/x-python","patch_set":4,"id":"3f79a3b5_140097ff","line":154,"range":{"start_line":154,"start_character":8,"end_line":154,"end_character":40},"updated":"2018-10-15 21:38:05.000000000","message":"Pretty sure we\u0027ve left the file open here.\n\n[Later] Yeah: https://www.logilab.org/blogentry/17873\n\nSince we\u0027re Linux, we could get away with:\n\n with tempfile.NamedTemporaryFile() as fh:\n     self._create_cfg_dr_iso(..., fh.name, ...)\n     vopt, f_uuid \u003d tsk_stg.upload_vopt(..., fh, fh.name, os.path.getsize(fh.name))\n\nThe file deletes itself.","commit_id":"91798b77cffbb57bf329801b2e2cc94bb7904047"},{"author":{"_account_id":14070,"name":"Eric Fried","email":"openstack@fried.cc","username":"efried"},"change_message_id":"c6415490ea313be9499ba614a066320d11a038cc","unresolved":false,"context_lines":[{"line_number":156,"context_line":"                                    fh.name, admin_pass\u003dadmin_pass)"},{"line_number":157,"context_line":"            vopt, f_uuid \u003d tsk_stg.upload_vopt("},{"line_number":158,"context_line":"                self.adapter, self.vios_uuid, fh, file_name,"},{"line_number":159,"context_line":"                os.path.getsize(fh.name))"},{"line_number":160,"context_line":""},{"line_number":161,"context_line":"        # Define the function to build and add the mapping"},{"line_number":162,"context_line":"        def add_func(vios_w):"}],"source_content_type":"text/x-python","patch_set":5,"id":"3f79a3b5_577a7875","line":159,"updated":"2018-10-16 19:54:24.000000000","message":"✔","commit_id":"5492eb5a0b80367a564e0b6a7653cb3278e395e4"}]}
