|
1 | | -import logging |
2 | 1 | from unittest.mock import PropertyMock, patch |
3 | 2 |
|
4 | 3 | from rest_framework import status |
@@ -61,6 +60,15 @@ def sample_report(): |
61 | 60 | totals=ReportTotals(files=2, lines=10, coverage=None), |
62 | 61 | ) |
63 | 62 | ) |
| 63 | + report.add_session( |
| 64 | + Session( |
| 65 | + flags=["no_coverage"], |
| 66 | + provider="travis", |
| 67 | + session_type=SessionType.uploaded, |
| 68 | + build="poli", |
| 69 | + totals=ReportTotals(files=0, lines=0, coverage=None), |
| 70 | + ) |
| 71 | + ) |
64 | 72 | return report |
65 | 73 |
|
66 | 74 |
|
@@ -1240,28 +1248,28 @@ def test_flag_component_badge(self, commit_components_mock, full_report_mock): |
1240 | 1248 | ) |
1241 | 1249 |
|
1242 | 1250 | expected_badge = """<svg xmlns="http://www.w3.org/2000/svg" width="122" height="20"> |
1243 | | - <linearGradient id="b" x2="0" y2="100%"> |
1244 | | - <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
1245 | | - <stop offset="1" stop-opacity=".1" /> |
1246 | | - </linearGradient> |
1247 | | - <mask id="a"> |
1248 | | - <rect width="122" height="20" rx="3" fill="#fff" /> |
1249 | | - </mask> |
1250 | | - <g mask="url(#a)"> |
1251 | | - <path fill="#555" d="M0 0h76v20H0z" /> |
1252 | | - <path fill="#4c1" d="M76 0h46v20H76z" /> |
1253 | | - <path fill="url(#b)" d="M0 0h122v20H0z" /> |
1254 | | - </g> |
1255 | | - <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
1256 | | - <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
1257 | | - <text x="46" y="14">codecov</text> |
1258 | | - <text x="98" y="15" fill="#010101" fill-opacity=".3">100%</text> |
1259 | | - <text x="98" y="14">100%</text> |
1260 | | - </g> |
1261 | | - <svg viewBox="140 -8 60 60"> |
1262 | | - <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
1263 | | - </svg> |
1264 | | -</svg>""" |
| 1251 | + <linearGradient id="b" x2="0" y2="100%"> |
| 1252 | + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
| 1253 | + <stop offset="1" stop-opacity=".1" /> |
| 1254 | + </linearGradient> |
| 1255 | + <mask id="a"> |
| 1256 | + <rect width="122" height="20" rx="3" fill="#fff" /> |
| 1257 | + </mask> |
| 1258 | + <g mask="url(#a)"> |
| 1259 | + <path fill="#555" d="M0 0h76v20H0z" /> |
| 1260 | + <path fill="#4c1" d="M76 0h46v20H76z" /> |
| 1261 | + <path fill="url(#b)" d="M0 0h122v20H0z" /> |
| 1262 | + </g> |
| 1263 | + <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
| 1264 | + <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
| 1265 | + <text x="46" y="14">codecov</text> |
| 1266 | + <text x="98" y="15" fill="#010101" fill-opacity=".3">100%</text> |
| 1267 | + <text x="98" y="14">100%</text> |
| 1268 | + </g> |
| 1269 | + <svg viewBox="140 -8 60 60"> |
| 1270 | + <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
| 1271 | + </svg> |
| 1272 | + </svg>""" |
1265 | 1273 |
|
1266 | 1274 | badge = response.content.decode("utf-8") |
1267 | 1275 | badge = [line.strip() for line in badge.split("\n")] |
@@ -1308,32 +1316,31 @@ def test_unknown_component_badge(self, commit_components_mock, full_report_mock) |
1308 | 1316 | ) |
1309 | 1317 |
|
1310 | 1318 | expected_badge = """<svg xmlns="http://www.w3.org/2000/svg" width="137" height="20"> |
1311 | | - <linearGradient id="b" x2="0" y2="100%"> |
1312 | | - <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
1313 | | - <stop offset="1" stop-opacity=".1" /> |
1314 | | - </linearGradient> |
1315 | | - <mask id="a"> |
1316 | | - <rect width="137" height="20" rx="3" fill="#fff" /> |
1317 | | - </mask> |
1318 | | - <g mask="url(#a)"> |
1319 | | - <path fill="#555" d="M0 0h76v20H0z" /> |
1320 | | - <path fill="#9f9f9f" d="M76 0h61v20H76z" /> |
1321 | | - <path fill="url(#b)" d="M0 0h137v20H0z" /> |
1322 | | - </g> |
1323 | | - <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
1324 | | - <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
1325 | | - <text x="46" y="14">codecov</text> |
1326 | | - <text x="105.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> |
1327 | | - <text x="105.5" y="14">unknown</text> |
1328 | | - </g> |
1329 | | - <svg viewBox="161 -8 60 60"> |
1330 | | - <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
1331 | | - </svg> |
1332 | | -</svg> |
1333 | | -""" |
| 1319 | + <linearGradient id="b" x2="0" y2="100%"> |
| 1320 | + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
| 1321 | + <stop offset="1" stop-opacity=".1" /> |
| 1322 | + </linearGradient> |
| 1323 | + <mask id="a"> |
| 1324 | + <rect width="137" height="20" rx="3" fill="#fff" /> |
| 1325 | + </mask> |
| 1326 | + <g mask="url(#a)"> |
| 1327 | + <path fill="#555" d="M0 0h76v20H0z" /> |
| 1328 | + <path fill="#9f9f9f" d="M76 0h61v20H76z" /> |
| 1329 | + <path fill="url(#b)" d="M0 0h137v20H0z" /> |
| 1330 | + </g> |
| 1331 | + <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
| 1332 | + <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
| 1333 | + <text x="46" y="14">codecov</text> |
| 1334 | + <text x="105.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> |
| 1335 | + <text x="105.5" y="14">unknown</text> |
| 1336 | + </g> |
| 1337 | + <svg viewBox="161 -8 60 60"> |
| 1338 | + <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
| 1339 | + </svg> |
| 1340 | + </svg> |
| 1341 | + """ |
1334 | 1342 |
|
1335 | 1343 | badge = response.content.decode("utf-8") |
1336 | | - logging.getLogger(__name__).warning(badge) |
1337 | 1344 | badge = [line.strip() for line in badge.split("\n")] |
1338 | 1345 | expected_badge = [line.strip() for line in expected_badge.split("\n")] |
1339 | 1346 | assert expected_badge == badge |
@@ -1378,32 +1385,102 @@ def test_component_badge_no_report(self, commit_components_mock, full_report_moc |
1378 | 1385 | ) |
1379 | 1386 |
|
1380 | 1387 | expected_badge = """<svg xmlns="http://www.w3.org/2000/svg" width="137" height="20"> |
1381 | | - <linearGradient id="b" x2="0" y2="100%"> |
1382 | | - <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
1383 | | - <stop offset="1" stop-opacity=".1" /> |
1384 | | - </linearGradient> |
1385 | | - <mask id="a"> |
1386 | | - <rect width="137" height="20" rx="3" fill="#fff" /> |
1387 | | - </mask> |
1388 | | - <g mask="url(#a)"> |
1389 | | - <path fill="#555" d="M0 0h76v20H0z" /> |
1390 | | - <path fill="#9f9f9f" d="M76 0h61v20H76z" /> |
1391 | | - <path fill="url(#b)" d="M0 0h137v20H0z" /> |
1392 | | - </g> |
1393 | | - <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
1394 | | - <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
1395 | | - <text x="46" y="14">codecov</text> |
1396 | | - <text x="105.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> |
1397 | | - <text x="105.5" y="14">unknown</text> |
1398 | | - </g> |
1399 | | - <svg viewBox="161 -8 60 60"> |
1400 | | - <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
1401 | | - </svg> |
1402 | | -</svg> |
1403 | | -""" |
| 1388 | + <linearGradient id="b" x2="0" y2="100%"> |
| 1389 | + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
| 1390 | + <stop offset="1" stop-opacity=".1" /> |
| 1391 | + </linearGradient> |
| 1392 | + <mask id="a"> |
| 1393 | + <rect width="137" height="20" rx="3" fill="#fff" /> |
| 1394 | + </mask> |
| 1395 | + <g mask="url(#a)"> |
| 1396 | + <path fill="#555" d="M0 0h76v20H0z" /> |
| 1397 | + <path fill="#9f9f9f" d="M76 0h61v20H76z" /> |
| 1398 | + <path fill="url(#b)" d="M0 0h137v20H0z" /> |
| 1399 | + </g> |
| 1400 | + <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
| 1401 | + <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
| 1402 | + <text x="46" y="14">codecov</text> |
| 1403 | + <text x="105.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> |
| 1404 | + <text x="105.5" y="14">unknown</text> |
| 1405 | + </g> |
| 1406 | + <svg viewBox="161 -8 60 60"> |
| 1407 | + <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
| 1408 | + </svg> |
| 1409 | + </svg> |
| 1410 | + """ |
| 1411 | + |
| 1412 | + badge = response.content.decode("utf-8") |
| 1413 | + badge = [line.strip() for line in badge.split("\n")] |
| 1414 | + expected_badge = [line.strip() for line in expected_badge.split("\n")] |
| 1415 | + assert expected_badge == badge |
| 1416 | + assert response.status_code == status.HTTP_200_OK |
| 1417 | + |
| 1418 | + @patch("core.models.Commit.full_report", new_callable=PropertyMock) |
| 1419 | + @patch("graphs.views.commit_components") |
| 1420 | + def test_component_badge_report_doesnt_have_matching_coverage( |
| 1421 | + self, commit_components_mock, full_report_mock |
| 1422 | + ): |
| 1423 | + gh_owner = OwnerFactory(service="github") |
| 1424 | + repo = RepositoryFactory( |
| 1425 | + author=gh_owner, |
| 1426 | + active=True, |
| 1427 | + private=False, |
| 1428 | + name="repo1", |
| 1429 | + yaml={ |
| 1430 | + "component_management": { |
| 1431 | + "individual_components": [ |
| 1432 | + { |
| 1433 | + "component_id": "no_coverage", |
| 1434 | + "name": "No Coverage", |
| 1435 | + "flag_regexes": ["no_coverage"], |
| 1436 | + } |
| 1437 | + ] |
| 1438 | + } |
| 1439 | + }, |
| 1440 | + ) |
| 1441 | + CommitFactory(repository=repo, author=gh_owner) |
| 1442 | + commit_components_mock.return_value = UserYaml.get_final_yaml( |
| 1443 | + repo_yaml=repo.yaml |
| 1444 | + ).get_components() |
| 1445 | + full_report_mock.return_value = sample_report() |
| 1446 | + |
| 1447 | + # test default precision |
| 1448 | + response = self._get( |
| 1449 | + kwargs={ |
| 1450 | + "service": "gh", |
| 1451 | + "owner_username": gh_owner.username, |
| 1452 | + "repo_name": "repo1", |
| 1453 | + "ext": "svg", |
| 1454 | + }, |
| 1455 | + data={"component": "no_coverage"}, |
| 1456 | + ) |
| 1457 | + |
| 1458 | + expected_badge = """<svg xmlns="http://www.w3.org/2000/svg" width="137" height="20"> |
| 1459 | + <linearGradient id="b" x2="0" y2="100%"> |
| 1460 | + <stop offset="0" stop-color="#bbb" stop-opacity=".1" /> |
| 1461 | + <stop offset="1" stop-opacity=".1" /> |
| 1462 | + </linearGradient> |
| 1463 | + <mask id="a"> |
| 1464 | + <rect width="137" height="20" rx="3" fill="#fff" /> |
| 1465 | + </mask> |
| 1466 | + <g mask="url(#a)"> |
| 1467 | + <path fill="#555" d="M0 0h76v20H0z" /> |
| 1468 | + <path fill="#9f9f9f" d="M76 0h61v20H76z" /> |
| 1469 | + <path fill="url(#b)" d="M0 0h137v20H0z" /> |
| 1470 | + </g> |
| 1471 | + <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11"> |
| 1472 | + <text x="46" y="15" fill="#010101" fill-opacity=".3">codecov</text> |
| 1473 | + <text x="46" y="14">codecov</text> |
| 1474 | + <text x="105.5" y="15" fill="#010101" fill-opacity=".3">unknown</text> |
| 1475 | + <text x="105.5" y="14">unknown</text> |
| 1476 | + </g> |
| 1477 | + <svg viewBox="161 -8 60 60"> |
| 1478 | + <path d="M23.013 0C10.333.009.01 10.22 0 22.762v.058l3.914 2.275.053-.036a11.291 11.291 0 0 1 8.352-1.767 10.911 10.911 0 0 1 5.5 2.726l.673.624.38-.828c.368-.802.793-1.556 1.264-2.24.19-.276.398-.554.637-.851l.393-.49-.484-.404a16.08 16.08 0 0 0-7.453-3.466 16.482 16.482 0 0 0-7.705.449C7.386 10.683 14.56 5.016 23.03 5.01c4.779 0 9.272 1.84 12.651 5.18 2.41 2.382 4.069 5.35 4.807 8.591a16.53 16.53 0 0 0-4.792-.723l-.292-.002a16.707 16.707 0 0 0-1.902.14l-.08.012c-.28.037-.524.074-.748.115-.11.019-.218.041-.327.063-.257.052-.51.108-.75.169l-.265.067a16.39 16.39 0 0 0-.926.276l-.056.018c-.682.23-1.36.511-2.016.838l-.052.026c-.29.145-.584.305-.899.49l-.069.04a15.596 15.596 0 0 0-4.061 3.466l-.145.175c-.29.36-.521.666-.723.96-.17.247-.34.513-.552.864l-.116.199c-.17.292-.32.57-.449.824l-.03.057a16.116 16.116 0 0 0-.843 2.029l-.034.102a15.65 15.65 0 0 0-.786 5.174l.003.214a21.523 21.523 0 0 0 .04.754c.009.119.02.237.032.355.014.145.032.29.049.432l.01.08c.01.067.017.133.026.197.034.242.074.48.119.72.463 2.419 1.62 4.836 3.345 6.99l.078.098.08-.095c.688-.81 2.395-3.38 2.539-4.922l.003-.029-.014-.025a10.727 10.727 0 0 1-1.226-4.956c0-5.76 4.545-10.544 10.343-10.89l.381-.014a11.403 11.403 0 0 1 6.651 1.957l.054.036 3.862-2.237.05-.03v-.056c.006-6.08-2.384-11.793-6.729-16.089C34.932 2.361 29.16 0 23.013 0" fill="#F01F7A" fill-rule="evenodd"/> |
| 1479 | + </svg> |
| 1480 | + </svg> |
| 1481 | + """ |
1404 | 1482 |
|
1405 | 1483 | badge = response.content.decode("utf-8") |
1406 | | - logging.getLogger(__name__).warning(badge) |
1407 | 1484 | badge = [line.strip() for line in badge.split("\n")] |
1408 | 1485 | expected_badge = [line.strip() for line in expected_badge.split("\n")] |
1409 | 1486 | assert expected_badge == badge |
|
0 commit comments