@@ -1330,6 +1330,76 @@ def test_unknown_component_badge(self, commit_components_mock, full_report_mock)
13301330 <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"/>
13311331 </svg>
13321332</svg>
1333+ """
1334+
1335+ badge = response .content .decode ("utf-8" )
1336+ logging .getLogger (__name__ ).warning (badge )
1337+ badge = [line .strip () for line in badge .split ("\n " )]
1338+ expected_badge = [line .strip () for line in expected_badge .split ("\n " )]
1339+ assert expected_badge == badge
1340+ assert response .status_code == status .HTTP_200_OK
1341+
1342+ @patch ("core.models.Commit.full_report" , new_callable = PropertyMock )
1343+ @patch ("graphs.views.commit_components" )
1344+ def test_component_badge_no_report (self , commit_components_mock , full_report_mock ):
1345+ gh_owner = OwnerFactory (service = "github" )
1346+ repo = RepositoryFactory (
1347+ author = gh_owner ,
1348+ active = True ,
1349+ private = False ,
1350+ name = "repo1" ,
1351+ yaml = {
1352+ "component_management" : {
1353+ "individual_components" : [
1354+ {
1355+ "component_id" : "unittests" ,
1356+ "name" : "Unit tests" ,
1357+ "flag_regexes" : ["unittests" ],
1358+ }
1359+ ]
1360+ }
1361+ },
1362+ )
1363+ CommitFactory (repository = repo , author = gh_owner )
1364+ commit_components_mock .return_value = UserYaml .get_final_yaml (
1365+ repo_yaml = repo .yaml
1366+ ).get_components ()
1367+ full_report_mock .return_value = None
1368+
1369+ # test default precision
1370+ response = self ._get (
1371+ kwargs = {
1372+ "service" : "gh" ,
1373+ "owner_username" : gh_owner .username ,
1374+ "repo_name" : "repo1" ,
1375+ "ext" : "svg" ,
1376+ },
1377+ data = {"component" : "unittests" },
1378+ )
1379+
1380+ 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>
13331403"""
13341404
13351405 badge = response .content .decode ("utf-8" )
0 commit comments