)]}'
{"/COMMIT_MSG":[{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"6f59147c2e89b83ef01bd8c1ecf063c0199bdb90","unresolved":false,"context_lines":[{"line_number":11,"context_line":"@mock.patch(\"abc\")"},{"line_number":12,"context_line":"def test_foobar(self, mock_abc)."},{"line_number":13,"context_line":""},{"line_number":14,"context_line":"Parital-Bug: #1462956"},{"line_number":15,"context_line":"Change-Id: I9eaab17bfc0e8c7b85eb56a51d4bcd5884480f2c"}],"source_content_type":"text/x-gerrit-commit-message","patch_set":8,"id":"3afb71cf_4522c4ba","line":14,"updated":"2015-06-08 18:04:18.000000000","message":"Typo: s/Parital/Partial/","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"}],"tests/unit/test_mock.py":[{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"6f59147c2e89b83ef01bd8c1ecf063c0199bdb90","unresolved":false,"context_lines":[{"line_number":69,"context_line":"    @classmethod"},{"line_number":70,"context_line":"    def camelcase_to_python(cls, name):"},{"line_number":71,"context_line":"        s1 \u003d re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)"},{"line_number":72,"context_line":"        return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", s1).lower()"},{"line_number":73,"context_line":""},{"line_number":74,"context_line":"    def _get_value(self, node):"},{"line_number":75,"context_line":"        \"\"\"Get mock.patch string argument."}],"source_content_type":"text/x-python","patch_set":8,"id":"3afb71cf_d772e748","line":72,"updated":"2015-06-08 18:04:18.000000000","message":"Compile these regexes as class variables.","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"},{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"dc0fc42d5d1a576d6aad205aac3cd824930e5d6b","unresolved":false,"context_lines":[{"line_number":123,"context_line":"    def visit_FunctionDef(self, node):"},{"line_number":124,"context_line":"        self.generic_visit(node)"},{"line_number":125,"context_line":""},{"line_number":126,"context_line":"        if not node.name.startswith(\"test_\"):"},{"line_number":127,"context_line":"            return"},{"line_number":128,"context_line":""},{"line_number":129,"context_line":"        mock_decs \u003d self._get_mock_decorators(node)"}],"source_content_type":"text/x-python","patch_set":8,"id":"3afb71cf_61d5adb7","line":126,"updated":"2015-06-08 20:11:54.000000000","message":"This is probably excessively narrow; in two cases we mock stuff on functions whose names do not start with test_. I think it\u0027s probably sufficient to check all functions that have mock decorators applied in files whose name starts with test_ in the tests path.\n\nExamples:\n\nhttps://github.com/openstack/rally/blob/master/tests%2Funit%2Fplugins%2Fopenstack%2Fscenarios%2Fnova%2Ftest_utils.py#L420\n\nhttps://github.com/openstack/rally/blob/master/tests/unit/deploy/test_engine.py#L204","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"},{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"6f59147c2e89b83ef01bd8c1ecf063c0199bdb90","unresolved":false,"context_lines":[{"line_number":137,"context_line":"            if (not dec.lower() in arg.lower() and"},{"line_number":138,"context_line":"               not arg.lower() in dec.lower()):"},{"line_number":139,"context_line":"                return False"},{"line_number":140,"context_line":"            return True"},{"line_number":141,"context_line":""},{"line_number":142,"context_line":"        for arg, dec in six.moves.zip_longest(mock_args, mock_decs):"},{"line_number":143,"context_line":"            if not _is_ok(arg, dec):"}],"source_content_type":"text/x-python","patch_set":8,"id":"3afb71cf_1ae4260b","line":140,"updated":"2015-06-08 18:04:18.000000000","message":"These four lines can be:\n\n    return (dec.lower() in arg.lower() or arg.lower() in dec.lower())\n\nAlthough I\u0027m not sure we want to lowercase them; camelcase_to_python already lowercases the decorator name, and lowercasing the argument name would miss things like:\n\n    @mock.patch(\"foo.Something\")\n    def test_blah(self, mock_Something):\n        ...\n\nIt seems like we should be checking to ensure that the decorator name ends with the argument name, and that\u0027s it. Otherwise, these would also be acceptable:\n\n    @mock.patch(\"foo.Something\")\n    def test_blah(self, mock_foo):\n        ...\n\n    @mock.patch(\"rally.common.utils.generate_random_name\")\n    def test_blah(self, mock_random):\n        ...\n\nSo I think this should do:\n\n    def _is_ok(arg, dec):\n        return arg is not None and dec is not None and dec.endswith(arg)\n\nThe downside here is that the mock argument names can sometimes get very long. E.g., this:\n\n    @mock.patch(SAHARA_NGTS + \"._list_node_group_templates\")\n    @mock.patch(SAHARA_NGTS + \"._create_master_node_group_template\",\n                return_value\u003dobject())\n    @mock.patch(SAHARA_NGTS + \"._create_worker_node_group_template\",\n                return_value\u003dobject)\n    def test_create_and_list_node_group_templates(self, mock_create_worker,\n                                                  mock_create_master,\n                                                  mock_list):\n\nBecomes:\n\n    def test_create_and_list_node_group_templates(\n            self, mock__create_worker_node_group_template,\n            mock__create_master_node_group_template,\n            mock__list_node_group_templates):\n\nBut the long mock argument names are purely a function of long function names, so the \"fix\" there is to rename the mocked function to something shorter, if that\u0027s an actual concern.","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"},{"author":{"_account_id":13609,"name":"Pavel Boldin","email":"pboldin@mirantis.com","username":"pboldin"},"change_message_id":"560870c39707dabd6b24084ecb1f375bbb7f0c50","unresolved":false,"context_lines":[{"line_number":137,"context_line":"            if (not dec.lower() in arg.lower() and"},{"line_number":138,"context_line":"               not arg.lower() in dec.lower()):"},{"line_number":139,"context_line":"                return False"},{"line_number":140,"context_line":"            return True"},{"line_number":141,"context_line":""},{"line_number":142,"context_line":"        for arg, dec in six.moves.zip_longest(mock_args, mock_decs):"},{"line_number":143,"context_line":"            if not _is_ok(arg, dec):"}],"source_content_type":"text/x-python","patch_set":8,"id":"3afb71cf_f778342d","line":140,"in_reply_to":"3afb71cf_1ae4260b","updated":"2015-06-09 00:38:42.000000000","message":"I agree that the naming convention is not that good but I\u0027m unable to come up with the one that is better from my mind.\n\nThat is, I agree with naming like `mock_create_master\u0027 and `mock_create_worker\u0027. Probably, something alike `arg.startswith(dec)\u0027 is a better thing to do.\n\nBut I\u0027m unable to think of a good naming convention as of yet. I think we should discuss it either in mailing list or IRC (or both).","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"},{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"6f59147c2e89b83ef01bd8c1ecf063c0199bdb90","unresolved":false,"context_lines":[{"line_number":144,"context_line":"                self.errors.append({"},{"line_number":145,"context_line":"                    \"lineno\": node.lineno,"},{"line_number":146,"context_line":"                    \"args\": mock_args,"},{"line_number":147,"context_line":"                    \"decs\": mock_decs"},{"line_number":148,"context_line":"                })"},{"line_number":149,"context_line":"                break"},{"line_number":150,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"3afb71cf_f72163fc","line":147,"updated":"2015-06-08 18:04:18.000000000","message":"Since this is presented to the developer, spell out \"decorators\". Also, report which specific pair isn\u0027t OK.","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"},{"author":{"_account_id":13609,"name":"Pavel Boldin","email":"pboldin@mirantis.com","username":"pboldin"},"change_message_id":"a4d48db1fad92a66fab934291a8c94b36145d5c2","unresolved":false,"context_lines":[{"line_number":144,"context_line":"                self.errors.append({"},{"line_number":145,"context_line":"                    \"lineno\": node.lineno,"},{"line_number":146,"context_line":"                    \"args\": mock_args,"},{"line_number":147,"context_line":"                    \"decs\": mock_decs"},{"line_number":148,"context_line":"                })"},{"line_number":149,"context_line":"                break"},{"line_number":150,"context_line":""}],"source_content_type":"text/x-python","patch_set":8,"id":"3afb71cf_cd47fa49","line":147,"in_reply_to":"3afb71cf_f72163fc","updated":"2015-06-09 00:34:11.000000000","message":"The pair reporting can\u0027t be done since there can be *no* valid args at all and there is no way to match them (there are sometimes arguments from ddt.ddt decorators).","commit_id":"b08baa5ce1604577939bfb794b40d78d781ca9af"},{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"03e913e902af24578e60b6b6f1cd3078dada9edd","unresolved":false,"context_lines":[{"line_number":77,"context_line":"    @classmethod"},{"line_number":78,"context_line":"    def camelcase_to_python(cls, name):"},{"line_number":79,"context_line":"        s1 \u003d re.sub(\"(.)([A-Z][a-z]+)\", r\"\\1_\\2\", name)"},{"line_number":80,"context_line":"        return re.sub(\"([a-z0-9])([A-Z])\", r\"\\1_\\2\", s1).lower()"},{"line_number":81,"context_line":""},{"line_number":82,"context_line":"    def _get_class_and_method_name_regexp(self, name, class_or_pkg_name\u003dTrue):"},{"line_number":83,"context_line":"        tokens \u003d name.split(\".\")"}],"source_content_type":"text/x-python","patch_set":10,"id":"fa32b979_71043017","line":80,"updated":"2015-06-17 20:24:41.000000000","message":"Compile these regexes as class variables.","commit_id":"cd44d92151b4b80766c8ec7f8b2183675e145de0"},{"author":{"_account_id":11748,"name":"Chris St. Pierre","email":"cstpierr@cisco.com","username":"stpierre"},"change_message_id":"03e913e902af24578e60b6b6f1cd3078dada9edd","unresolved":false,"context_lines":[{"line_number":180,"context_line":"    def visit_FunctionDef(self, node):"},{"line_number":181,"context_line":"        self.generic_visit(node)"},{"line_number":182,"context_line":""},{"line_number":183,"context_line":"        if not node.name.startswith(\"test_\"):"},{"line_number":184,"context_line":"            return"},{"line_number":185,"context_line":""},{"line_number":186,"context_line":"        mock_decs \u003d self._get_mock_decorators_regexp(node)"}],"source_content_type":"text/x-python","patch_set":10,"id":"fa32b979_314c689d","line":183,"updated":"2015-06-17 20:24:41.000000000","message":"This is probably excessively narrow; in at least one case we mock stuff on functions whose names do not start with test_. I think it\u0027s probably sufficient to check all functions that have mock decorators applied in files whose name starts with test_ in the tests path.\n\nExample: https://github.com/openstack/rally/blob/master/tests/unit/deploy/test_engine.py#L180","commit_id":"cd44d92151b4b80766c8ec7f8b2183675e145de0"},{"author":{"_account_id":13609,"name":"Pavel Boldin","email":"pboldin@mirantis.com","username":"pboldin"},"change_message_id":"e49f46eb3483313f06f799272b515c265bdfcea9","unresolved":false,"context_lines":[{"line_number":124,"context_line":""},{"line_number":125,"context_line":"    def _get_mocked_name_regexp(self, name):"},{"line_number":126,"context_line":"        tokens \u003d name.split(\".\")"},{"line_number":127,"context_line":"        if len(tokens) \u003e 1:"},{"line_number":128,"context_line":"            name \u003d self._camelcase_to_python(tokens.pop())"},{"line_number":129,"context_line":"            if tokens[-1][0].isupper():"},{"line_number":130,"context_line":"                # Mocked something inside a class, check if we should require"}],"source_content_type":"text/x-python","patch_set":11,"id":"fa32b979_b2ec7e90","line":127,"updated":"2015-06-21 18:42:10.000000000","message":"If there is only one \u0027name\u0027 then there is no camel-case to python conversion.","commit_id":"dff19ed1d8f646198358b05595df66520b861592"}]}
