Page MenuHomeSoftware Heritage

Jenkins > .tox.py3.lib.python3.7.site-packages.swh.web.tests.misc.test_coverage::Tests / Python tests / test_coverage_view_with_metrics
Failed

TEST RESULT

Run At
Aug 31 2021, 3:42 PM
Details
client = <django.test.client.Client object at 0x7fe4f6bf7ba8> swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7fe4f734c438> mocker = <pytest_mock.plugin.MockerFixture object at 0x7fe4fad92a90> def test_coverage_view_with_metrics(client, swh_scheduler, mocker): """ Generate some sample scheduler metrics and some sample deposits that will be consumed by the archive coverage view, then check the HTML page gets rendered without errors. """ listers = [] for origins in listed_origins["origins"]: # create some instances for each lister for instance in range(randint(1, 5)): lister = swh_scheduler.get_or_create_lister( origins["type"], f"instance-{instance}" ) listers.append(lister) # record some sample listed origins _origins = [] origin_visit_stats = [] for i in range(randint(3, 10)): url = str(uuid.uuid4()) visit_type = choice(["git", "hg", "svn"]) _origins.append( ListedOrigin( lister_id=lister.id, url=url, visit_type=visit_type, extra_loader_arguments={}, ) ) # set origin visit stats to some origins if i % 2 == 0: now = datetime.now(tz=timezone.utc) origin_visit_stats.append( OriginVisitStats( url=url, visit_type=visit_type, last_successful=now, last_visit=now, last_visit_status=LastVisitStatus.successful, last_snapshot=os.urandom(20), ) ) # send origins data to scheduler swh_scheduler.record_listed_origins(_origins) swh_scheduler.origin_visit_stats_upsert(origin_visit_stats) # compute scheduler metrics swh_scheduler.update_metrics() # add some sample deposits deposits = [] for origins in deposited_origins["origins"]: for _ in range(randint(2, 10)): deposits.append( { "origin_url": f"https://{origins['search_pattern']}/{uuid.uuid4()}", "status": "done", } ) get_deposits_list = mocker.patch("swh.web.misc.coverage.get_deposits_list") get_deposits_list.return_value = deposits # check view gets rendered without errors url = reverse("swh-coverage") resp = check_html_get_response( client, url, status_code=200, template_used="misc/coverage.html" ) # check logos and origins search links are present in the rendered page for origins in chain( listed_origins["origins"], legacy_origins["origins"], deposited_origins["origins"], miscellaneous_origins["origins"], ): logo_url = f'{settings.STATIC_URL}img/logos/{origins["type"].lower()}.png' assert_contains(resp, f'src="{logo_url}"') if "instances" in origins: for visit_types in origins["instances"].values(): for data in visit_types.values(): if data["count"]: assert_contains( > resp, f'<a href="{escape(data["search_url"])}">' ) .tox/py3/lib/python3.7/site-packages/swh/web/tests/misc/test_coverage.py:130: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ .tox/py3/lib/python3.7/site-packages/django/test/testcases.py:454: in assertContains self.assertTrue(real_count != 0, msg_prefix + "Couldn't find %s in response" % text_repr) _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = <django.test.testcases.TestCase testMethod=run>, expr = False msg = 'False is not true : Couldn\'t find \'<a href="/browse/search/?q=instance-0&amp;visit_type=svn&amp;with_content=true&amp;with_visit=true">\' in response' def assertTrue(self, expr, msg=None): """Check that the expression is true.""" if not expr: msg = self._formatMessage(msg, "%s is not true" % safe_repr(expr)) > raise self.failureException(msg) E AssertionError: False is not true : Couldn't find '<a href="/browse/search/?q=instance-0&amp;visit_type=svn&amp;with_content=true&amp;with_visit=true">' in response /usr/lib/python3.7/unittest/case.py:692: AssertionError