Skip to content

Commit

Permalink
Fix upload sarif data test for Python < 3.11
Browse files Browse the repository at this point in the history
It seems that gzip.compress creates different data with Python < 3.11
and therefore the sarif data passed to the http post can't be checked in
the tests.
  • Loading branch information
bjoernricks committed Oct 19, 2023
1 parent e033971 commit b57030d
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions tests/github/api/test_code_scanning.py
Original file line number Diff line number Diff line change
Expand Up @@ -1325,14 +1325,22 @@ async def test_upload_sarif_data(self):
ref="refs/heads/master",
sarif=json.dumps(sarif).encode(),
)
self.client.post.assert_awaited_once_with(
"/repos/foo/bar/code-scanning/sarifs",
data={
"commit_sha": "4b6472266afd7b471e86085a6659e8c7f2b119da",
"ref": "refs/heads/master",
"sarif": "H4sIAAAAAAACA7VSO2/cMAz+K4JQIEttJUW73Jp2CHBbkC5FBsXm2Qpk0SCl6wUH//eSsu/aoshYaNGD/F7i2R6BOGCyO2M/tXftrf1o7AfuRpi83o05zzvnXhlTu95yRoIWaXDsKRya2tVQntrP2kslsTT+ONuMGGV3tj0FYanb5CdQ2G+P+5Cy1od0QJp8Fg1PFC6ULJzAUWqUacWNsAGHXssSNiUVhr45emIt4REpfwXuKMx59SQq4JS1vA/sY8SfZm0y0hT8i2Iu0jpCnN+ldz127KoA9y/rTDgD5VDVnW3nMwxIbwr1/TfH8rwoj5fCg+/y5iRi569Ky8p/CBGE3t3vXA/HNeQt6lwk++Ajy3maVc5DyoR96RTEcdDLBk71sX2ttBodcIlXSjiCfosFIiQ1MAGzH+CvtG5ONyaw8cxhSJKWl7xiAfNSskmCQEYzaGt2FxMbwTy+ceh83P/p7eJ7/58N14Hq4SS4t0u1PlzYOIsImTo1eqfToud7jGXS9y/LlpX88sM781XfrujPsn4BtlGkUj8DAAA=",
},

self.assertEqual(self.client.post.await_count, 1)
args = self.client.post.await_args
self.assertEqual(args.args, ("/repos/foo/bar/code-scanning/sarifs",))
data = args.kwargs["data"]
self.assertEqual(
data["commit_sha"],
"4b6472266afd7b471e86085a6659e8c7f2b119da",
)
self.assertEqual(
data["ref"],
"refs/heads/master",
)
# it's not possible to check the sarif data in Python < 3.11 because
# gzip creates different content on each run
self.assertTrue("sarif" in data)

self.assertEqual(resp["id"], "47177e22-5596-11eb-80a1-c1e54ef945c6")
self.assertEqual(
Expand Down

0 comments on commit b57030d

Please sign in to comment.