client = <django.test.client.Client object at 0x7f3942fdaf98>
swh_scheduler = <swh.scheduler.backend.SchedulerBackend object at 0x7f3942fdae10>
mocker = <pytest_mock.plugin.MockerFixture object at 0x7f3942fdacf8>
def test_coverage_view(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=binary(min_size=20, max_size=20).example(),
)
)
# 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['netloc']}/{uuid.uuid4()}",
"status": "done",
}
)
E KeyError: 'netloc'
.tox/py3/lib/python3.7/site-packages/swh/web/tests/misc/test_coverage.py:72: KeyError
TEST RESULT
TEST RESULT
- Run At
- Aug 24 2021, 5:42 PM