-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Render built-in dashboard locally during tests
You can now see the dashboard built with mock data in dashboard_dev/ by running the test_dashboard_template.py module. This enables you to quickly refine the built-in template.
- Loading branch information
1 parent
16d0bca
commit e02282f
Showing
3 changed files
with
97 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
"""Test the built-in dashboard template by rendering to a local directory.""" | ||
|
||
from __future__ import annotations | ||
|
||
from datetime import datetime, timezone | ||
from pathlib import Path | ||
from typing import List | ||
|
||
from keeper.dashboard.context import ( | ||
BuildContext, | ||
BuildContextList, | ||
EditionContext, | ||
EditionContextList, | ||
ProjectContext, | ||
) | ||
from keeper.dashboard.templateproviders import BuiltinTemplateProvider | ||
from keeper.models import EditionKind | ||
|
||
|
||
def test_templates() -> None: | ||
output_dir = Path(__file__).parent.parent.joinpath("dashboard_dev") | ||
|
||
# Create mock data | ||
project = ProjectContext( | ||
title="LTD Test Project", | ||
source_repo_url="https://github.com/lsst-sqre/ltd-keeper", | ||
url="https://example.com/ltd-test/", | ||
) | ||
editions: List[EditionContext] = [] | ||
builds: List[BuildContext] = [] | ||
|
||
editions.append( | ||
EditionContext( | ||
title="Current", | ||
url="https://example.com/ltd-test/", | ||
date_updated=datetime(2022, 6, 21, tzinfo=timezone.utc), | ||
kind=EditionKind.main, | ||
slug="__main", | ||
git_ref="main", | ||
) | ||
) | ||
|
||
builds.append( | ||
BuildContext( | ||
slug="1", | ||
url="https://example.com/ltd-test/builds/1", | ||
git_ref="main", | ||
date=datetime(2022, 6, 21, tzinfo=timezone.utc), | ||
) | ||
) | ||
|
||
template = BuiltinTemplateProvider() | ||
template.render_locally( | ||
directory=output_dir, | ||
project_context=project, | ||
edition_contexts=EditionContextList(editions), | ||
build_contexts=BuildContextList(builds), | ||
) |