-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1668 from bhilbert4/data-containers-to-use-django
Update data_containers and bokeh_dashboard to use Django models
- Loading branch information
Showing
5 changed files
with
149 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/usr/bin/env python | ||
|
||
"""Tests for the ``bokeh_dashboard`` module in the ``jwql`` web | ||
application. | ||
Authors | ||
------- | ||
- Bryan Hilbert | ||
Use | ||
--- | ||
These tests can be run via the command line (omit the -s to | ||
suppress verbose output to stdout): | ||
:: | ||
pytest -s test_bokeh_dashboard.py | ||
""" | ||
|
||
import os | ||
|
||
from django import setup | ||
import pandas as pd | ||
import pytest | ||
|
||
from jwql.utils.constants import DEFAULT_MODEL_CHARFIELD, ON_GITHUB_ACTIONS, ON_READTHEDOCS | ||
|
||
# Skip testing this module if on Github Actions | ||
if not ON_GITHUB_ACTIONS and not ON_READTHEDOCS: | ||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "jwql.website.jwql_proj.settings") | ||
setup() | ||
from jwql.website.apps.jwql import bokeh_dashboard # noqa: E402 (module level import not at top of file) | ||
|
||
|
||
@pytest.mark.skipif(ON_GITHUB_ACTIONS, reason='Requires access to django models.') | ||
def test_build_table_latest_entry(): | ||
tab = bokeh_dashboard.build_table('FilesystemCharacteristics') | ||
assert isinstance(tab, pd.DataFrame) | ||
assert len(tab['date']) > 0 |
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,30 @@ | ||
#! /usr/bin/env python | ||
|
||
""" | ||
apps.py is the standard and recommended way to configure application-specific settings | ||
in Django, including tasks like importing additional modules during initialization. | ||
Author | ||
------ | ||
B. Hilbert | ||
""" | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class JwqlAppConfig(AppConfig): | ||
default_auto_field = 'django.db.models.BigAutoField' | ||
name = 'jwql' | ||
|
||
def ready(self): | ||
# Import models not defined in models.py here | ||
# By importing these models here, they will be available | ||
# to the build_table() function. | ||
import jwql.website.apps.jwql.monitor_models.bad_pixel | ||
import jwql.website.apps.jwql.monitor_models.bias | ||
import jwql.website.apps.jwql.monitor_models.claw | ||
import jwql.website.apps.jwql.monitor_models.common | ||
import jwql.website.apps.jwql.monitor_models.dark_current | ||
import jwql.website.apps.jwql.monitor_models.readnoise | ||
import jwql.website.apps.jwql.monitor_models.ta |
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
Oops, something went wrong.