From 0331733546307a10eb317552535aaa1ca3aab1e5 Mon Sep 17 00:00:00 2001 From: devdanzin <74280297+devdanzin@users.noreply.github.com> Date: Thu, 17 Oct 2024 12:30:21 -0300 Subject: [PATCH 1/4] Update Branch.sync_with_upstream to correcly send required data. --- AUTHORS.rst | 2 ++ src/github3/repos/branch.py | 8 ++------ tests/cassettes/Branch_sync_with_upstream.json | 1 + tests/integration/test_repos_branch.py | 15 +++++++++++++++ tests/unit/test_repos_branch.py | 15 ++++++++++++++- 5 files changed, 34 insertions(+), 7 deletions(-) create mode 100644 tests/cassettes/Branch_sync_with_upstream.json diff --git a/AUTHORS.rst b/AUTHORS.rst index 1946eda3..c28d9b35 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -226,3 +226,5 @@ Contributors - Thomas Buchner (@MrBatschner) - Chris Cotter (@ccotter) + +- Daniel Diniz (@devdanzin) diff --git a/src/github3/repos/branch.py b/src/github3/repos/branch.py index 8ebaaeb7..8b941a57 100644 --- a/src/github3/repos/branch.py +++ b/src/github3/repos/branch.py @@ -166,17 +166,13 @@ def protect( def sync_with_upstream(self) -> t.Mapping[str, str]: """Synchronize this branch with the upstream. - .. warning:: - - This API endpoint is still in Beta per gitHub - .. versionadded:: 3.0.0 Sync a branch of a forked repository to keep it up-to-date with the upstream repository. See also: - https://docs.github.com/en/rest/reference/repos#sync-a-fork-branch-with-the-upstream-repository + https://docs.github.com/en/rest/branches/branches#sync-a-fork-branch-with-the-upstream-repository :returns: The dictionary described in the documentation @@ -185,7 +181,7 @@ def sync_with_upstream(self) -> t.Mapping[str, str]: """ base = self._api.split("/branches", 1)[0] url = self._build_url("merge-upstream", base_url=base) - json = self._json(self._post(url), 200) + json = self._json(self._post(url, data={"branch": self.name}), 200) return json @decorators.requires_auth diff --git a/tests/cassettes/Branch_sync_with_upstream.json b/tests/cassettes/Branch_sync_with_upstream.json new file mode 100644 index 00000000..0a7e6369 --- /dev/null +++ b/tests/cassettes/Branch_sync_with_upstream.json @@ -0,0 +1 @@ +{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token "]}, "method": "GET", "uri": "https://api.github.com/repos/devdanzin/cpython"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA+2ba2/bNhSG/0rhr0siy5c4MRB0xeoFHea6TdytyDAItEzbTGRJEyl7iZD/vsOLbowvMuXtw+AvbSzzfXl4eBH5hEkaZNrod9o9u3vdbbfPGn4wxQ5/1rhznuYfR7fzy9vJ1wZ8gZYYnrrhM1sEPjyYxZ7nqKdTvJoi/4X4Vv59GJEVYqCZIY/is0aw9nHU6CcNL5gTH6wyEZjxGnud1lWzdd0rBjH8+PXyt++fPffRbQ4f5+vh41MbiiNwRpETRx74LBgLad+y5EN6MSdsEU9iiiM38Bn22YUbLK3YSv3fr2464DGPlItoLTzQ3EKinKQc7KhVDHnBlp4WgaxZlC+WnAWeF6xBrwe8swork/FkCwviz00sQJZYAVtgyBg045U3nlB2YDhCklj8Pxgg3IRCH0R4elhISgQB8fHwmlgRDgPhFk+oG5GQkcA/MLSSFKyCaI588oIMrEBKwYEHdWAQQgJSvIIhd6BWahJLzBn3macjwi4mK8iuiZ8mBjv2HPLp+w36n+eaMOyg6ZLPQzE9X89gGlUaz4UZPsVZh4H1eIHffRGLw7swCmB2LcF+/s5D/jxGcwy1zoLoqdFnUQyrwc7JJlKZT6FCldxiT263iGE6gRSieMLPhg5cmVjwrxr/LkxKNAkixIJ9c3tbUCWLxCp+5IOAYbQ0DFZIwWIRBKYZE1KwIJTGuNI43NZM4UCtdJj78XIi16Eqg3ubqdRCfIhSMvcxNsxUJk+sdHmcRMh3F6aGqTqx5E+iJ9HcMDyuBIOJF0wMHeC1ZAl5YtEFkss/c8wj4n5cXbKL8KxG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qAASlzlCW/2IS0p5aYUjkLfxoNh5/GznBwf//hdnDPZ1+hyWl5YQ7pVqVHd86XO2f8afzrAATFTED4qfO2EqnXcHB3O0gr5n0IOxo+uxPBLK+Am15dX9plZjlYj7xfPPf2+gV9v1u5/lNnOP7WHX18ag2/3tzk02AzTJWrzCEkNWOyPCS724KY9IieR0/Xzw+tn2P0PVxMb73V5HFgDx95VAMekRFRVVXVAKpZ5LvpUw6dD0GpKpHGHLWkrwNRlVEtgqo8jodPU8MidoWBcDA7VT6HglMlE3s5qLYKCOJ0hlpKeBxkmkVRgq0Qj+KlowJJ5ovOwdxUVZDPdDNomq6l5V94lH9/ILfFbyqsjEzLyoN5qSavDUs1v2ORUs32YEyq6U0ZqWZzBECqOZrRUc2kJhrV3OpwUb3bDoSimpzjGnMiusHMGIdu8DJjoRuMzEGoZlaPgmpm5gj0bVSKn8LKfCj/1LyKcr7OHwY/9cByde5VmXxuNhNy0c7K2PNNE4XSlHluGF91gOeG4GrTTs3zSKjzTaTiTgE145xvzAQhrQU5NUsTwqlZHAdvaqZmbHNjlxqBTc2pJtXUk34cpKm5/hs8U6uiDszUrGqSTH245ByUr3pljGn3zpuAMZtj+7rfave79k6M2e3bV33JKLdhzG6/edXvdPZgzHKI+xjmxtJ7AOZGDd1FL8sKSNVedCmOMZxcXra7cOFqE7m8bDf5XTCdXqrH+wimpFT/OcBsN+1raM2RIOZVrwcIBajf/5ljqpSVWKZseNr1fJSIsbAZaQKApEEcuYL0nnjYiYft+4V8CeGceFjhaqlayE88rNIlwhMPO/Gwws3v/SBU3T2Ezc9BtwW1XemJh1XINIdrJx4m/yShQrpOPCz/C44K6Sre9T/xsOxvXypk7sTDqt7401b9Ew8r/ZlVhaGWXxGsdcVP64cTDxP3Ak88bMdtvhMPS6/hnXhYemmx8r2+Y/AwH7M1XEfUeqH4C8X0wuXrP8LCaJR9OwAA", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:14 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"8f47f7c7601f53b27d896470216b96e512d311317207af2dae3ff4692348f62f\""], "Last-Modified": ["Thu, 17 Oct 2024 14:13:30 GMT"], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-accepted-github-permissions": ["metadata=read"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4996"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["4"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:4759A3:4BDA74:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython"}, "recorded_at": "2024-10-17T15:20:14"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.loki-preview+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token "]}, "method": "GET", "uri": "https://api.github.com/repos/devdanzin/cpython/branches/main"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA71Ya3OjxhL9K5TyJYnX4SkeruTeIIFkPRAW1jvacvEYBBIMCAYk4/J/z4xke2XvZq/lTV1XqcoM06e7p+dMn+GhBu0Y1K5qsR3C2qeam8RxiGpXD7U8sPEwLymyCGSecWyu7nEuL3OKLDuM6DiAkwSWqSsiL4guNoWJB+5CDxs17zY7zWyvxLbjJWpPM3hztOIWo1VltLuBsZ5sjNioTK1TN7UgNLRFOI/H94NquDe0cX2wNphBbLwKxi5QkGQkrKdwjdANbBBRWpYAhJwkifF8gJOISC4eGfhzRR5/wxnhV56NSJYcwwmXLHPJSiOWu+KYK55Z1B6f00bg1EU7RNeFcwILkwyk0f2fqxAFhfM+4Bjkub0irlfBJcvxbJ2/olrhnrppm5RThJGXUzuMR/kZAJcoyIDthXBFJZCahtBLdjn1808sVxcZ6ZclXMJfqbNwlhk2wr9fKQt4CRUkOwoFgPrJA34IAbVLsk2OM0TY+ZeaM9if4nFS3fbqLmsLcl1mBJl3eU4WXAX4dcAoksIJ2LDIyHoHCKX5FU3bafjbl8Wh8WolOe2B0rNhFULaTe9xFSGNp9DEY06/2xMu0YddHbd0Tp+xlYkJgOjOTQqIycB8qpUgC/3QtVGYQLJSx2eAdzvKCvCphuuWkze10o4wBz7V8nAFbVRkpPSX5K+htzsDXPYb6rbTHqijsaUfxklVd3nLbahqo6mqw8awC/WhbjatJmsPpaKoj4NIVdVJjxmqvdLrzVJJndnQjeaWxY0AiBl/CdUiHl2zWYKQ0TbyKLaUtiHqc1+P9MauUzZBz1oM+onbS4JpdKEzs0Dz2/1mXZosoqY62iwhUCRJdrfimGPyut2Lvb68U5rFmL+xsiLtwtn8Xh33EBtbRlSO22pm7fYXpcG10PA2mHSCJdy2U7OQenF/kGp8M41YZDXl2Y3Fm/TUC5L0ogGAVKmDKcdkimy6E7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EH6NvV0fCuZMwNtyOPpH6LfM/4PMPAk4u9z8GTiWSx8tvs4D98g/AgTX6B+iIsvKP8eG79AnvL4I3x8QTqXkS+G53PyxfTfYeVJJK8Y/S5eHmVZXrv66/nTwnsVGob/0N3vuXGf4ef7VPtHLfJuD4+f8Ql1F4UQ37rJJxYQ+edfn50MX/4CfHt++mRDgj5B+a54Ilr6aIcDSfF1EbiIXGIPp+fLyNMdF0DbiU7eZmBbhKQvYn6hIr/DQbjHRAD0k8wFhztzhDcbiSfxfVy5gy7ZI1L3z/jpyeKvz0RhPvnH3r7fmf7pO8KrhcAd55ANif3xb6kfti3WEgAA", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:14 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"ff2877c6e7c6074caa640ac16bc243d0c41c49597a4972116cf3eebf0d5aaf68\""], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=loki-preview; format=json"], "x-accepted-github-permissions": ["contents=read"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4995"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["5"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:4759F5:4BDAC4:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython/branches/main"}, "recorded_at": "2024-10-17T15:20:14"}, {"request": {"body": {"encoding": "utf-8", "string": "{\"branch\": \"main\"}"}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Content-Length": ["18"], "Authorization": ["token "]}, "method": "POST", "uri": "https://api.github.com/repos/devdanzin/cpython/merge-upstream"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA02MSwrDMAwFryK0bnuAXKMHCIotxYX4gywTTOjdq+6yfG+YuTBz77QzLvgeIfiQcRwThC0kjkAlglC3p1Q9SaNfojXDaN2UKUOblmpZMn3KCx+e051Xm+1fvIvONuq8bkolJIc3Eb8/6CBOGIgAAAA=", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:15 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"5f066f9e4b594b308e099fe06dd359a6998faafa1d5d359df0e6a2e50d3b6de4\""], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-accepted-github-permissions": ["contents=write"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4994"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["6"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:475A21:4BDAEF:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython/merge-upstream"}, "recorded_at": "2024-10-17T15:20:15"}], "recorded_with": "betamax/0.9.0"} \ No newline at end of file diff --git a/tests/integration/test_repos_branch.py b/tests/integration/test_repos_branch.py index 63aef805..652c1921 100644 --- a/tests/integration/test_repos_branch.py +++ b/tests/integration/test_repos_branch.py @@ -33,3 +33,18 @@ def test_latest_sha_differs(self): latest_sha = branch.latest_sha(differs_from=sha) assert not isinstance(latest_sha, bytes) + + def test_sync_with_upstream(self): + self.token_login() + cassette_name = self.cassette_name("sync_with_upstream") + betamax_kwargs = { + "match_requests_on": ["method", "uri", "if-none-match"] + } + with self.recorder.use_cassette(cassette_name, **betamax_kwargs): + repository = self.gh.repository("devdanzin", "cpython") + branch = repository.branch("main") + result = branch.sync_with_upstream() + + assert result["message"] == "Successfully fetched and fast-forwarded from upstream python:main." + assert result["merge_type"] == "fast-forward" + assert result["base_branch"] == "python:main" diff --git a/tests/unit/test_repos_branch.py b/tests/unit/test_repos_branch.py index f381e200..423ca49d 100644 --- a/tests/unit/test_repos_branch.py +++ b/tests/unit/test_repos_branch.py @@ -11,7 +11,9 @@ url_for_commits = helper.create_url_helper( "https://api.github.com/repos/octocat/Hello-World/commits/master" ) - +url_for_sync = helper.create_url_helper( + "https://api.github.com/repos/octocat/Hello-World/merge-upstream" +) class TestBranch(helper.UnitHelper): """Branch unit tests.""" @@ -30,6 +32,13 @@ def test_latest_sha(self): url_for_commits(), headers=headers ) + def test_sync_with_upstream(self): + """Verify the request fot syncing a branch with upstream.""" + self.instance.sync_with_upstream() + self.session.post.assert_called_once_with( + url_for_sync(), '{"branch": "master"}' + ) + def test_unprotect(self): """Verify the request to unprotect a branch.""" self.instance.unprotect() @@ -44,6 +53,10 @@ class TestBranchRequiresAuth(helper.UnitRequiresAuthenticationHelper): described_class = github3.repos.branch.Branch example_data = get_example_data() + def test_sync_with_upstream(self): + """Verify that syncing a branch with upstream requires authentication.""" + self.assert_requires_auth(self.instance.sync_with_upstream) + def test_protect(self): """Verify that protecting a branch requires authentication.""" self.assert_requires_auth(self.instance.protect) From 8cd694f64bfa6ae5269bc2f619ead97e64e78b8c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:08:26 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- tests/cassettes/Branch_sync_with_upstream.json | 2 +- tests/integration/test_repos_branch.py | 5 ++++- tests/unit/test_repos_branch.py | 1 + 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tests/cassettes/Branch_sync_with_upstream.json b/tests/cassettes/Branch_sync_with_upstream.json index 0a7e6369..aacdb812 100644 --- a/tests/cassettes/Branch_sync_with_upstream.json +++ b/tests/cassettes/Branch_sync_with_upstream.json @@ -1 +1 @@ -{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token "]}, "method": "GET", "uri": "https://api.github.com/repos/devdanzin/cpython"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA+2ba2/bNhSG/0rhr0siy5c4MRB0xeoFHea6TdytyDAItEzbTGRJEyl7iZD/vsOLbowvMuXtw+AvbSzzfXl4eBH5hEkaZNrod9o9u3vdbbfPGn4wxQ5/1rhznuYfR7fzy9vJ1wZ8gZYYnrrhM1sEPjyYxZ7nqKdTvJoi/4X4Vv59GJEVYqCZIY/is0aw9nHU6CcNL5gTH6wyEZjxGnud1lWzdd0rBjH8+PXyt++fPffRbQ4f5+vh41MbiiNwRpETRx74LBgLad+y5EN6MSdsEU9iiiM38Bn22YUbLK3YSv3fr2464DGPlItoLTzQ3EKinKQc7KhVDHnBlp4WgaxZlC+WnAWeF6xBrwe8swork/FkCwviz00sQJZYAVtgyBg045U3nlB2YDhCklj8Pxgg3IRCH0R4elhISgQB8fHwmlgRDgPhFk+oG5GQkcA/MLSSFKyCaI588oIMrEBKwYEHdWAQQgJSvIIhd6BWahJLzBn3macjwi4mK8iuiZ8mBjv2HPLp+w36n+eaMOyg6ZLPQzE9X89gGlUaz4UZPsVZh4H1eIHffRGLw7swCmB2LcF+/s5D/jxGcwy1zoLoqdFnUQyrwc7JJlKZT6FCldxiT263iGE6gRSieMLPhg5cmVjwrxr/LkxKNAkixIJ9c3tbUCWLxCp+5IOAYbQ0DFZIwWIRBKYZE1KwIJTGuNI43NZM4UCtdJj78XIi16Eqg3ubqdRCfIhSMvcxNsxUJk+sdHmcRMh3F6aGqTqx5E+iJ9HcMDyuBIOJF0wMHeC1ZAl5YtEFkss/c8wj4n5cXbKL8KxGeFyd2bHIuC9FaFyemcH7hkG3GsaWqq1EZS5dzgz9Mjn0KH8TztHL3n3BtvGf68GMb3UiMonrLEW5A49Ovo5hnho2tW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0gr5n0IOxo+uxPBLK+Am15dX9plZjlYj7xfPPf2+gV9v1u5/lNnOP7WHX18ag2/3tzk02AzTJWrzCEkNWOyPCS724KY9IieR0/Xzw+tn2P0PVxMb73V5HFgDx95VAMekRFRVVXVAKpZ5LvpUw6dD0GpKpHGHLWkrwNRlVEtgqo8jodPU8MidoWBcDA7VT6HglMlE3s5qLYKCOJ0hlpKeBxkmkVRgq0Qj+KlowJJ5ovOwdxUVZDPdDNomq6l5V94lH9/ILfFbyqsjEzLyoN5qSavDUs1v2ORUs32YEyq6U0ZqWZzBECqOZrRUc2kJhrV3OpwUb3bDoSimpzjGnMiusHMGIdu8DJjoRuMzEGoZlaPgmpm5gj0bVSKn8LKfCj/1LyKcr7OHwY/9cByde5VmXxuNhNy0c7K2PNNE4XSlHluGF91gOeG4GrTTs3zSKjzTaTiTgE145xvzAQhrQU5NUsTwqlZHAdvaqZmbHNjlxqBTc2pJtXUk34cpKm5/hs8U6uiDszUrGqSTH245ByUr3pljGn3zpuAMZtj+7rfave79k6M2e3bV33JKLdhzG6/edXvdPZgzHKI+xjmxtJ7AOZGDd1FL8sKSNVedCmOMZxcXra7cOFqE7m8bDf5XTCdXqrH+wimpFT/OcBsN+1raM2RIOZVrwcIBajf/5ljqpSVWKZseNr1fJSIsbAZaQKApEEcuYL0nnjYiYft+4V8CeGceFjhaqlayE88rNIlwhMPO/Gwws3v/SBU3T2Ezc9BtwW1XemJh1XINIdrJx4m/yShQrpOPCz/C44K6Sre9T/xsOxvXypk7sTDqt7401b9Ew8r/ZlVhaGWXxGsdcVP64cTDxP3Ak88bMdtvhMPS6/hnXhYemmx8r2+Y/AwH7M1XEfUeqH4C8X0wuXrP8LCaJR9OwAA", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:14 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"8f47f7c7601f53b27d896470216b96e512d311317207af2dae3ff4692348f62f\""], "Last-Modified": ["Thu, 17 Oct 2024 14:13:30 GMT"], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-accepted-github-permissions": ["metadata=read"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4996"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["4"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:4759A3:4BDA74:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython"}, "recorded_at": "2024-10-17T15:20:14"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.loki-preview+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token "]}, "method": "GET", "uri": "https://api.github.com/repos/devdanzin/cpython/branches/main"}, "response": {"body": {"encoding": "utf-8", "base64_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PyxfTfYeVJJK8Y/S5eHmVZXrv66/nTwnsVGob/0N3vuXGf4ef7VPtHLfJuD4+f8Ql1F4UQ37rJJxYQ+edfn50MX/4CfHt++mRDgj5B+a54Ilr6aIcDSfF1EbiIXGIPp+fLyNMdF0DbiU7eZmBbhKQvYn6hIr/DQbjHRAD0k8wFhztzhDcbiSfxfVy5gy7ZI1L3z/jpyeKvz0RhPvnH3r7fmf7pO8KrhcAd55ANif3xb6kfti3WEgAA", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:14 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"ff2877c6e7c6074caa640ac16bc243d0c41c49597a4972116cf3eebf0d5aaf68\""], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=loki-preview; format=json"], "x-accepted-github-permissions": ["contents=read"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4995"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["5"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:4759F5:4BDAC4:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython/branches/main"}, "recorded_at": "2024-10-17T15:20:14"}, {"request": {"body": {"encoding": "utf-8", "string": "{\"branch\": \"main\"}"}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Content-Length": ["18"], "Authorization": ["token "]}, "method": "POST", "uri": "https://api.github.com/repos/devdanzin/cpython/merge-upstream"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA02MSwrDMAwFryK0bnuAXKMHCIotxYX4gywTTOjdq+6yfG+YuTBz77QzLvgeIfiQcRwThC0kjkAlglC3p1Q9SaNfojXDaN2UKUOblmpZMn3KCx+e051Xm+1fvIvONuq8bkolJIc3Eb8/6CBOGIgAAAA=", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:15 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"5f066f9e4b594b308e099fe06dd359a6998faafa1d5d359df0e6a2e50d3b6de4\""], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-accepted-github-permissions": ["contents=write"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4994"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["6"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:475A21:4BDAEF:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython/merge-upstream"}, "recorded_at": "2024-10-17T15:20:15"}], "recorded_with": "betamax/0.9.0"} \ No newline at end of file +{"http_interactions": [{"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token "]}, "method": "GET", "uri": "https://api.github.com/repos/devdanzin/cpython"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA+2ba2/bNhSG/0rhr0siy5c4MRB0xeoFHea6TdytyDAItEzbTGRJEyl7iZD/vsOLbowvMuXtw+AvbSzzfXl4eBH5hEkaZNrod9o9u3vdbbfPGn4wxQ5/1rhznuYfR7fzy9vJ1wZ8gZYYnrrhM1sEPjyYxZ7nqKdTvJoi/4X4Vv59GJEVYqCZIY/is0aw9nHU6CcNL5gTH6wyEZjxGnud1lWzdd0rBjH8+PXyt++fPffRbQ4f5+vh41MbiiNwRpETRx74LBgLad+y5EN6MSdsEU9iiiM38Bn22YUbLK3YSv3fr2464DGPlItoLT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ZmbHNjlxqBTc2pJtXUk34cpKm5/hs8U6uiDszUrGqSTH245ByUr3pljGn3zpuAMZtj+7rfave79k6M2e3bV33JKLdhzG6/edXvdPZgzHKI+xjmxtJ7AOZGDd1FL8sKSNVedCmOMZxcXra7cOFqE7m8bDf5XTCdXqrH+wimpFT/OcBsN+1raM2RIOZVrwcIBajf/5ljqpSVWKZseNr1fJSIsbAZaQKApEEcuYL0nnjYiYft+4V8CeGceFjhaqlayE88rNIlwhMPO/Gwws3v/SBU3T2Ezc9BtwW1XemJh1XINIdrJx4m/yShQrpOPCz/C44K6Sre9T/xsOxvXypk7sTDqt7401b9Ew8r/ZlVhaGWXxGsdcVP64cTDxP3Ak88bMdtvhMPS6/hnXhYemmx8r2+Y/AwH7M1XEfUeqH4C8X0wuXrP8LCaJR9OwAA", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:14 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"8f47f7c7601f53b27d896470216b96e512d311317207af2dae3ff4692348f62f\""], "Last-Modified": ["Thu, 17 Oct 2024 14:13:30 GMT"], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-accepted-github-permissions": ["metadata=read"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4996"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["4"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:4759A3:4BDA74:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython"}, "recorded_at": "2024-10-17T15:20:14"}, {"request": {"body": {"encoding": "utf-8", "string": ""}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.loki-preview+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Authorization": ["token "]}, "method": "GET", "uri": "https://api.github.com/repos/devdanzin/cpython/branches/main"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA71Ya3OjxhL9K5TyJYnX4SkeruTeIIFkPRAW1jvacvEYBBIMCAYk4/J/z4xke2XvZq/lTV1XqcoM06e7p+dMn+GhBu0Y1K5qsR3C2qeam8RxiGpXD7U8sPEwLymyCGSecWyu7nEuL3OKLDuM6DiAkwSWqSsiL4guNoWJB+5CDxs17zY7zWyvxLbjJWpPM3hztOIWo1VltLuBsZ5sjNioTK1TN7UgNLRFOI/H94NquDe0cX2wNphBbLwKxi5QkGQkrKdwjdANbBBRWpYAhJwkifF8gJOISC4eGfhzRR5/wxnhV56NSJYcwwmXLHPJSiOWu+KYK55Z1B6f00bg1EU7RNeFcwILkwyk0f2fqxAFhfM+4Bjkub0irlfBJcvxbJ2/olrhnrppm5RThJGXUzuMR/kZAJcoyIDthXBFJZCahtBLdjn1808sVxcZ6ZclXMJfqbNwlhk2wr9fKQt4CRUkOw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fZ7jvTrrs3zd5zhW9liBEXHBj72F+rqjUL+/bST/oViJU1hREnmGumQEhlnC4/GCWwd1bBjU71/3iW/ZLeFZJ/n/tSM8fvS8/cBZG6A4unt9uJ/0kK+7x9HFB07z/I2Xd3arc1Oin5oH6atfZEuUrLC+epYm+BURSkRMCafCydCG4mQ2iNy1IRjrDUMgShvZ2dvQD4P5U7MtcpC5CUR42xNRQhf0Afi/5R+kRa+yJ4iDNPtfPZtg5fRx3+O53y/OyzQ/iaJkhy3fxvlaEJyC0y822M3xf6x7zrbHNg90gjUNXiIc+iNJOMzROYEc5j9gVZIjLF8JQo4XNwPeGcE8WeBQdhBH8XDQPgeowsndLEyJbjgnqFd2GCfJVjYMq4P+OAcH25GNeJBiZ+RzmI/tQIk31TmGR4MHOs3C0nbvyRJkwAVhiZfzbLA3lhgL3adEUI1xqcnihgjc2V5MmOXbUQ7eKvln1u2Ac+njHYptCAtYfKcRBEH6NvV0fCuZMwNtyOPpH6LfM/4PMPAk4u9z8GTiWSx8tvs4D98g/AgTX6B+iIsvKP8eG79AnvL4I3x8QTqXkS+G53PyxfTfYeVJJK8Y/S5eHmVZXrv66/nTwnsVGob/0N3vuXGf4ef7VPtHLfJuD4+f8Ql1F4UQ37rJJxYQ+edfn50MX/4CfHt++mRDgj5B+a54Ilr6aIcDSfF1EbiIXGIPp+fLyNMdF0DbiU7eZmBbhKQvYn6hIr/DQbjHRAD0k8wFhztzhDcbiSfxfVy5gy7ZI1L3z/jpyeKvz0RhPvnH3r7fmf7pO8KrhcAd55ANif3xb6kfti3WEgAA", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:14 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"ff2877c6e7c6074caa640ac16bc243d0c41c49597a4972116cf3eebf0d5aaf68\""], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=loki-preview; format=json"], "x-accepted-github-permissions": ["contents=read"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4995"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["5"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:4759F5:4BDAC4:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython/branches/main"}, "recorded_at": "2024-10-17T15:20:14"}, {"request": {"body": {"encoding": "utf-8", "string": "{\"branch\": \"main\"}"}, "headers": {"User-Agent": ["github3.py/4.0.1"], "Accept-Encoding": ["gzip, deflate"], "Accept": ["application/vnd.github.v3.full+json"], "Connection": ["keep-alive"], "Accept-Charset": ["utf-8"], "Content-Type": ["application/json"], "Content-Length": ["18"], "Authorization": ["token "]}, "method": "POST", "uri": "https://api.github.com/repos/devdanzin/cpython/merge-upstream"}, "response": {"body": {"encoding": "utf-8", "base64_string": "H4sIAAAAAAAAA02MSwrDMAwFryK0bnuAXKMHCIotxYX4gywTTOjdq+6yfG+YuTBz77QzLvgeIfiQcRwThC0kjkAlglC3p1Q9SaNfojXDaN2UKUOblmpZMn3KCx+e051Xm+1fvIvONuq8bkolJIc3Eb8/6CBOGIgAAAA=", "string": ""}, "headers": {"Date": ["Thu, 17 Oct 2024 15:20:15 GMT"], "Content-Type": ["application/json; charset=utf-8"], "Cache-Control": ["private, max-age=60, s-maxage=60"], "Vary": ["Accept, Authorization, Cookie, X-GitHub-OTP,Accept-Encoding, Accept, X-Requested-With"], "ETag": ["W/\"5f066f9e4b594b308e099fe06dd359a6998faafa1d5d359df0e6a2e50d3b6de4\""], "github-authentication-token-expiration": ["2025-01-15 11:11:08 -0300"], "X-GitHub-Media-Type": ["github.v3; param=full; format=json"], "x-accepted-github-permissions": ["contents=write"], "x-github-api-version-selected": ["2022-11-28"], "X-RateLimit-Limit": ["5000"], "X-RateLimit-Remaining": ["4994"], "X-RateLimit-Reset": ["1729181822"], "X-RateLimit-Used": ["6"], "X-RateLimit-Resource": ["core"], "Access-Control-Expose-Headers": ["ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"], "Access-Control-Allow-Origin": ["*"], "Strict-Transport-Security": ["max-age=31536000; includeSubdomains; preload"], "X-Frame-Options": ["deny"], "X-Content-Type-Options": ["nosniff"], "X-XSS-Protection": ["0"], "Referrer-Policy": ["origin-when-cross-origin, strict-origin-when-cross-origin"], "Content-Security-Policy": ["default-src 'none'"], "Content-Encoding": ["gzip"], "Transfer-Encoding": ["chunked"], "Server": ["github.com"], "X-GitHub-Request-Id": ["5820:26AC7A:475A21:4BDAEF:67112B2E"]}, "status": {"code": 200, "message": "OK"}, "url": "https://api.github.com/repos/devdanzin/cpython/merge-upstream"}, "recorded_at": "2024-10-17T15:20:15"}], "recorded_with": "betamax/0.9.0"} diff --git a/tests/integration/test_repos_branch.py b/tests/integration/test_repos_branch.py index 652c1921..27ebeaeb 100644 --- a/tests/integration/test_repos_branch.py +++ b/tests/integration/test_repos_branch.py @@ -45,6 +45,9 @@ def test_sync_with_upstream(self): branch = repository.branch("main") result = branch.sync_with_upstream() - assert result["message"] == "Successfully fetched and fast-forwarded from upstream python:main." + assert ( + result["message"] + == "Successfully fetched and fast-forwarded from upstream python:main." + ) assert result["merge_type"] == "fast-forward" assert result["base_branch"] == "python:main" diff --git a/tests/unit/test_repos_branch.py b/tests/unit/test_repos_branch.py index 423ca49d..dd59f6dd 100644 --- a/tests/unit/test_repos_branch.py +++ b/tests/unit/test_repos_branch.py @@ -15,6 +15,7 @@ "https://api.github.com/repos/octocat/Hello-World/merge-upstream" ) + class TestBranch(helper.UnitHelper): """Branch unit tests.""" From 2db3d7cb05d2b3044e020625dab0237a130dca97 Mon Sep 17 00:00:00 2001 From: devdanzin <74280297+devdanzin@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:20:04 -0300 Subject: [PATCH 3/4] Fix lint errors. --- tests/integration/test_repos_branch.py | 7 ++++--- tests/unit/test_repos_branch.py | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/integration/test_repos_branch.py b/tests/integration/test_repos_branch.py index 27ebeaeb..3f469107 100644 --- a/tests/integration/test_repos_branch.py +++ b/tests/integration/test_repos_branch.py @@ -45,9 +45,10 @@ def test_sync_with_upstream(self): branch = repository.branch("main") result = branch.sync_with_upstream() - assert ( - result["message"] - == "Successfully fetched and fast-forwarded from upstream python:main." + msg = ( + "Successfully fetched and fast-forwarded" + "from upstream python:main." ) + assert result["message"] == msg assert result["merge_type"] == "fast-forward" assert result["base_branch"] == "python:main" diff --git a/tests/unit/test_repos_branch.py b/tests/unit/test_repos_branch.py index dd59f6dd..72580a35 100644 --- a/tests/unit/test_repos_branch.py +++ b/tests/unit/test_repos_branch.py @@ -55,7 +55,7 @@ class TestBranchRequiresAuth(helper.UnitRequiresAuthenticationHelper): example_data = get_example_data() def test_sync_with_upstream(self): - """Verify that syncing a branch with upstream requires authentication.""" + """Verify that branch syncing with upstream requires authentication.""" self.assert_requires_auth(self.instance.sync_with_upstream) def test_protect(self): From 09592ff929fbb92954f9cca0f17806cce550070b Mon Sep 17 00:00:00 2001 From: devdanzin <74280297+devdanzin@users.noreply.github.com> Date: Thu, 17 Oct 2024 13:59:58 -0300 Subject: [PATCH 4/4] Fix silly test error. --- tests/integration/test_repos_branch.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/test_repos_branch.py b/tests/integration/test_repos_branch.py index 3f469107..c77d1e80 100644 --- a/tests/integration/test_repos_branch.py +++ b/tests/integration/test_repos_branch.py @@ -47,7 +47,7 @@ def test_sync_with_upstream(self): msg = ( "Successfully fetched and fast-forwarded" - "from upstream python:main." + " from upstream python:main." ) assert result["message"] == msg assert result["merge_type"] == "fast-forward"