Files
home-information/docs/dev/Testing.md
Tony C 036f39d2c4 Add new weather module (#41)
* Added initial scaffolding for weather support.

* Code cleanup and refactor around SecurityManager accesses.

* Added initial pass for an internal, unified weather data model.

* Added display unit conversions and UI testing page for weather app.

* Added template scaffolding and initial data model for weather.

* Finished templates and test data scaffolding for weather views.

* Added user setting for geo location (lat/long).

* WIP for weather monitors and NWS API integration.

* Beter factoring and parsing for NWS weather data source.

* Added WMO units and unit test for it. WIP for NWS weather source.

* Added unit tests for weather app (transient) models.

* Added unit test for NWS weather source observation parsing.

* Renamed a bunch of mixin file names for pluralization consistency.

* Straggler (missed) mixin file name change from previous commit.

* Added folding in of updated weath data into WeatherManager.

* Fixed some bug around fetching NWS data for the first time.

* Added WeatherStation to data model. WIP

* Finished adding new WeatherStation to weather data model.

* Added weather stations to UI.

* Added fetching NWS forecast data (hourly and 12 hour).

* Added three-valued parsing for NWS data: min, ave, max

* Updated weather synthetic data for recent model tweaks.

* Some variable/class renaming. Prep for forecast data model changes.

* Added StatisticDataPoint for min/max/ave values.

* Some minor refactoring to improve class naming and structures.

* Saving WIP for weather data aggregation class and data structures.

* Added improvement to dev docs.

* From strudel...more weather work.

* Removed redundant "elevation" model fields.

* Completed initial weather integrations w/Claude Code.

* Implement auto-discovery weather source configuration system

* Fix weather module unit test failures and improve WMO units handling

* Add git commit message guidelines to CLAUDE.md

* Expand testing infrastructure documentation with comprehensive high-value testing patterns and system architecture insights

* Fixed a few weather app bugs.

* Weather data inspection script and weather app bug fixes.

* More weather bug fixes and unit tests.

* More testing and fixing of initial weather app.

* Added sunrise-sunset.org integration. Fixed boolean config bug.

* Fixed astronomical data integration.

* Added future astronomical data frim sunrise-sunset.org API.

* Added USNO API data for sun and moon.

* Added weather alert data from NWS. Still need to map to Alarms.

* Added mapping weather alerts to system Alarms.

* Added tracking min/max daily temperatures.

* Tweaks and refinements for weather alerts.

* Last weather app tweaks before declaring first version done.

* Moved console context processor to more logical location.

* Fixed and updates some unit tests.

* Coding style fixes for weather module.

* Updated dev workflow doc.

* Fixed a bunch of code formatting.

* A few more code style fixes.

* Added missing import.
2025-08-13 14:47:04 -05:00

2.0 KiB

Home Information Logo

Testing

Unit Tests

./manage.py test

Integation Tests

TBD

Visual Testing Page

Visit: http://127.0.0.1:8411/tests/ui.

These tests/ui views are only available in the development environment when DEBUG=True. (They are conditionally loaded in the root urls.py.)

Adding to the Visual Testing Page

The hi.tests.ui module uses auto-discovery by looking in the app directories.

In the app directory you want to have a visual testing page:

mkdir -p tests/ui
touch tests.__init__.py
touch tests/ui.__init__.py

Then:

  • Create tests/ui/views.py
  • Create tests/ui/urls.py (This gets auto-discovered. Esnure some default home page rule.)

The templates for these tests, by convention, would be put in the app templates directory as templates/${APPNAME}/tests/ui. At a minimum, you will probably want a home page templates/${APPNAME}/tests/ui/home.html like this:

{% extends "pages/base.html" %}
{% block head_title %}HI: PAGE TITLE{% endblock %}

{% block content %}
<div class="container-fluid m-4">

  <h2 class="text-info">SOME TESTS</h2>

  <!-- Put links to views here -->

</div>
{% endblock %}

And in tests/ui/views.py:

class Test${APPNAMNE}HomeView( View ):

    def get(self, request, *args, **kwargs):
        context = {
        }
        return render(request, "${APPNAME}/tests/ui/home.html", context )

And in tests/ui/urls.py:

from django.urls import re_path

from . import views


urlpatterns = [

    re_path( r'^$',
             views.TestUi${APPNAME}HomeView.as_view(), 
             name='${APPNAME}_tests_ui'),
]

Email Testing

There are some helper base classes to test viewing email formatting and sending emails.

hi.tests.ui.email_test_views.py

This requires the email templates follow the naming patterns expected in view classes.