def test_upgrade_configuration( self, run_fixme, get_errors, remove_version, call ) -> None: arguments = MagicMock() get_errors.return_value = [] upgrade.run_fixme_all(arguments, []) run_fixme.assert_not_called() call.assert_not_called() errors = [ { "line": 2, "column": 4, "path": "local.py", "code": 7, "name": "Kind", "description": "Error", "inference": {}, "ignore_error": False, "external_to_global_root": False, } ] get_errors.return_value = errors configuration = upgrade.Configuration( "/root/local/.pyre_configuration.local", {} ) configuration.get_path() upgrade._upgrade_configuration(arguments, configuration, "/root") run_fixme.called_once_with(arguments, _result(errors)) call.assert_called_once_with( ["hg", "commit", "--message", "[typing] Update pyre version for local"] )
def test_run_fixme_single(self, run_fixme, get_errors, remove_version, find_configuration, call) -> None: arguments = MagicMock() arguments.path = "local" get_errors.return_value = [] configuration_contents = '{"targets":[]}' with patch("builtins.open", mock_open(read_data=configuration_contents)): upgrade.run_fixme_single(arguments, []) run_fixme.assert_not_called() call.assert_not_called() configuration_contents = '{"version": 123}' with patch("builtins.open", mock_open(read_data=configuration_contents)): upgrade.run_fixme_single(arguments, []) run_fixme.assert_not_called() call.assert_called_once_with([ "hg", "commit", "--message", upgrade._commit_message("local") ]) run_fixme.reset_mock() call.reset_mock() errors = [{ "line": 2, "column": 4, "path": "local.py", "code": 7, "name": "Kind", "description": "Error", "inference": {}, "ignore_error": False, "external_to_global_root": False, }] get_errors.return_value = errors with patch("builtins.open", mock_open(read_data=configuration_contents)): upgrade.run_fixme_single(arguments, []) run_fixme.called_once_with(arguments, _result(errors)) call.assert_called_once_with([ "hg", "commit", "--message", upgrade._commit_message("local") ])
def test_run_fixme_all( self, run_fixme, run_global_version_update, get_errors, remove_version, find_configuration, gather, call, ) -> None: arguments = MagicMock() gather.return_value = [ upgrade.Configuration("local/.pyre_configuration.local", {"version": 123}) ] get_errors.return_value = [] upgrade.run_fixme_all(arguments, []) run_global_version_update.assert_not_called() run_fixme.assert_not_called() call.assert_called_once_with( ["hg", "commit", "--message", upgrade._commit_message("local")]) run_fixme.reset_mock() call.reset_mock() errors = [{ "line": 2, "column": 4, "path": "local.py", "code": 7, "name": "Kind", "description": "Error", "inference": {}, "ignore_error": False, "external_to_global_root": False, }] get_errors.return_value = errors upgrade.run_fixme_all(arguments, []) run_global_version_update.assert_not_called() run_fixme.called_once_with(arguments, _result(errors)) call.assert_called_once_with( ["hg", "commit", "--message", upgrade._commit_message("local")]) run_fixme.reset_mock() call.reset_mock() gather.return_value = [ upgrade.Configuration("local/.pyre_configuration.local", {}) ] upgrade.run_fixme_all(arguments, []) run_fixme.assert_not_called() call.assert_not_called() run_fixme.reset_mock() call.reset_mock() gather.return_value = [ upgrade.Configuration("local/.pyre_configuration.local", {"version": 123}) ] arguments.hash = "abc" upgrade.run_fixme_all(arguments, []) run_global_version_update.assert_called_once_with(arguments, []) run_fixme.called_once_with(arguments, _result(errors)) call.assert_called_once_with( ["hg", "commit", "--message", upgrade._commit_message("local")])