2026-04-16 03:03:19 -04:00
|
|
|
"""Integration tests for the My Sky dashboard views.
|
|
|
|
|
|
|
|
|
|
sky_view — GET /dashboard/sky/ → renders sky template
|
2026-04-21 20:07:40 -04:00
|
|
|
sky_preview — GET /dashboard/sky/preview → proxies to PySwiss (no DB write)
|
2026-04-22 02:13:29 -04:00
|
|
|
sky_save — POST /dashboard/sky/save → saves natal data to User model;
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
grants Stargazer Note on first save with real chart_data
|
2026-04-16 03:03:19 -04:00
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
from unittest.mock import patch, MagicMock
|
|
|
|
|
|
|
|
|
|
from django.test import TestCase
|
|
|
|
|
from django.urls import reverse
|
|
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
from apps.drama.models import Note
|
2026-04-16 03:03:19 -04:00
|
|
|
from apps.lyric.models import User
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkyViewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
|
|
|
|
|
def test_sky_view_renders_template(self):
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertTemplateUsed(response, "apps/dashboard/sky.html")
|
|
|
|
|
|
|
|
|
|
def test_sky_view_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_sky_view_passes_preview_and_save_urls(self):
|
|
|
|
|
response = self.client.get(reverse("sky"))
|
|
|
|
|
self.assertContains(response, reverse("sky_preview"))
|
|
|
|
|
self.assertContains(response, reverse("sky_save"))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkyPreviewTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_preview")
|
|
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1"})
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_missing_params_returns_400(self):
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15"})
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_invalid_lat_returns_400(self):
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "999", "lon": "0"})
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
@patch("apps.dashboard.views.http_requests")
|
|
|
|
|
def test_proxies_to_pyswiss_and_returns_chart(self, mock_requests):
|
|
|
|
|
chart_payload = {
|
|
|
|
|
"planets": {"Sun": {"degree": 84.5, "sign": "Gemini", "retrograde": False}},
|
|
|
|
|
"houses": {"cusps": [0]*12},
|
|
|
|
|
"elements": {"Fire": 1, "Earth": 0, "Air": 0, "Water": 0},
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
}
|
|
|
|
|
tz_response = MagicMock()
|
|
|
|
|
tz_response.json.return_value = {"timezone": "Europe/London"}
|
|
|
|
|
tz_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
chart_response = MagicMock()
|
|
|
|
|
chart_response.json.return_value = chart_payload
|
|
|
|
|
chart_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
mock_requests.get.side_effect = [tz_response, chart_response]
|
|
|
|
|
|
|
|
|
|
response = self.client.get(self.url, {
|
|
|
|
|
"date": "1990-06-15", "time": "09:30",
|
|
|
|
|
"lat": "51.5074", "lon": "-0.1278",
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
data = response.json()
|
|
|
|
|
self.assertIn("planets", data)
|
|
|
|
|
# Earth→Stone rename applied
|
|
|
|
|
self.assertIn("Stone", data["elements"])
|
|
|
|
|
self.assertNotIn("Earth", data["elements"])
|
|
|
|
|
self.assertIn("timezone", data)
|
|
|
|
|
self.assertIn("distinctions", data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkySaveTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_save")
|
|
|
|
|
|
|
|
|
|
def _post(self, payload):
|
|
|
|
|
return self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=json.dumps(payload),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self._post({})
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_get_not_allowed(self):
|
|
|
|
|
response = self.client.get(self.url)
|
|
|
|
|
self.assertEqual(response.status_code, 405)
|
|
|
|
|
|
|
|
|
|
def test_saves_sky_fields_to_user(self):
|
|
|
|
|
payload = {
|
|
|
|
|
"birth_dt": "1990-06-15T08:30:00",
|
|
|
|
|
"birth_lat": 51.5074,
|
|
|
|
|
"birth_lon": -0.1278,
|
|
|
|
|
"birth_place": "London, UK",
|
|
|
|
|
"house_system": "O",
|
2026-04-21 20:07:40 -04:00
|
|
|
"chart_data": {},
|
2026-04-16 03:03:19 -04:00
|
|
|
}
|
|
|
|
|
response = self._post(payload)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertEqual(str(self.user.sky_birth_dt), "1990-06-15 08:30:00+00:00")
|
|
|
|
|
self.assertAlmostEqual(float(self.user.sky_birth_lat), 51.5074, places=3)
|
|
|
|
|
self.assertAlmostEqual(float(self.user.sky_birth_lon), -0.1278, places=3)
|
|
|
|
|
self.assertEqual(self.user.sky_birth_place, "London, UK")
|
|
|
|
|
self.assertEqual(self.user.sky_house_system, "O")
|
|
|
|
|
|
|
|
|
|
def test_invalid_json_returns_400(self):
|
|
|
|
|
response = self.client.post(
|
|
|
|
|
self.url, data="not json", content_type="application/json"
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_response_contains_saved_flag(self):
|
|
|
|
|
payload = {
|
|
|
|
|
"birth_dt": "1990-06-15T08:30:00",
|
|
|
|
|
"birth_lat": 51.5,
|
|
|
|
|
"birth_lon": -0.1,
|
|
|
|
|
"birth_place": "",
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
"chart_data": {},
|
|
|
|
|
}
|
|
|
|
|
data = self._post(payload).json()
|
|
|
|
|
self.assertTrue(data["saved"])
|
COVERAGE: patch 91% → 96%+ — 603 tests, tasks.py at 100%
New/extended tests across billboard, dashboard, drama, epic, gameboard,
and lyric to cover previously untested branches: dev_login view, scroll
position endpoints, sky preview error paths, drama to_prose/to_activity
branches, consumer broadcast handlers, tarot deck draw/shuffle, astrology
model __str__, character model, sig reserve/ready/confirm views, natus
preview/save views, and the full tasks.py countdown scheduler.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-17 23:23:28 -04:00
|
|
|
|
|
|
|
|
def test_invalid_birth_dt_string_sets_sky_birth_dt_to_none(self):
|
|
|
|
|
payload = {
|
|
|
|
|
"birth_dt": "not-a-date",
|
|
|
|
|
"birth_lat": 51.5,
|
|
|
|
|
"birth_lon": -0.1,
|
|
|
|
|
"birth_place": "",
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
"chart_data": {},
|
|
|
|
|
}
|
|
|
|
|
response = self._post(payload)
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertIsNone(self.user.sky_birth_dt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkyPreviewErrorPathTest(TestCase):
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star2@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_preview")
|
|
|
|
|
|
|
|
|
|
def test_non_numeric_lat_returns_400(self):
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "abc", "lon": "0"})
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_invalid_tz_string_returns_400(self):
|
|
|
|
|
response = self.client.get(
|
|
|
|
|
self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1", "tz": "Not/ATimezone"}
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
def test_bad_date_format_returns_400(self):
|
|
|
|
|
response = self.client.get(
|
|
|
|
|
self.url,
|
|
|
|
|
{"date": "not-a-date", "time": "09:00", "lat": "51.5", "lon": "-0.1", "tz": "UTC"},
|
|
|
|
|
)
|
|
|
|
|
self.assertEqual(response.status_code, 400)
|
|
|
|
|
|
|
|
|
|
@patch("apps.dashboard.views.http_requests")
|
|
|
|
|
def test_pyswiss_tz_failure_falls_back_to_utc_and_continues(self, mock_requests):
|
|
|
|
|
chart_payload = {
|
|
|
|
|
"planets": {"Sun": {"degree": 84.5, "sign": "Gemini", "retrograde": False}},
|
|
|
|
|
"houses": {"cusps": [0] * 12},
|
|
|
|
|
"elements": {},
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
}
|
|
|
|
|
tz_response = MagicMock()
|
|
|
|
|
tz_response.raise_for_status.side_effect = Exception("tz timeout")
|
|
|
|
|
|
|
|
|
|
chart_response = MagicMock()
|
|
|
|
|
chart_response.json.return_value = chart_payload
|
|
|
|
|
chart_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
mock_requests.get.side_effect = [tz_response, chart_response]
|
|
|
|
|
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1"})
|
|
|
|
|
self.assertEqual(response.status_code, 200)
|
|
|
|
|
self.assertEqual(response.json()["timezone"], "UTC")
|
|
|
|
|
|
|
|
|
|
@patch("apps.dashboard.views.http_requests")
|
|
|
|
|
def test_pyswiss_chart_failure_returns_502(self, mock_requests):
|
|
|
|
|
tz_response = MagicMock()
|
|
|
|
|
tz_response.json.return_value = {"timezone": "UTC"}
|
|
|
|
|
tz_response.raise_for_status = MagicMock()
|
|
|
|
|
|
|
|
|
|
chart_response = MagicMock()
|
|
|
|
|
chart_response.raise_for_status.side_effect = Exception("chart timeout")
|
|
|
|
|
|
|
|
|
|
mock_requests.get.side_effect = [tz_response, chart_response]
|
|
|
|
|
|
|
|
|
|
response = self.client.get(self.url, {"date": "1990-06-15", "lat": "51.5", "lon": "-0.1"})
|
|
|
|
|
self.assertEqual(response.status_code, 502)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
_REAL_CHART = {
|
|
|
|
|
"planets": {"Sun": {"degree": 66.7, "sign": "Gemini", "retrograde": False}},
|
|
|
|
|
"houses": {"cusps": [180, 210, 240, 270, 300, 330, 0, 30, 60, 90, 120, 150]},
|
|
|
|
|
"elements": {"Fire": 1, "Stone": 2, "Air": 4, "Water": 0, "Time": 1, "Space": 1},
|
|
|
|
|
"aspects": [],
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
class SkySaveNoteTest(TestCase):
|
|
|
|
|
"""sky_save grants the Stargazer Note on the first save with real chart_data."""
|
2026-04-22 02:13:29 -04:00
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_save")
|
|
|
|
|
|
|
|
|
|
def _post(self, chart_data=_REAL_CHART):
|
|
|
|
|
return self.client.post(
|
|
|
|
|
self.url,
|
|
|
|
|
data=json.dumps({
|
|
|
|
|
"birth_dt": "1990-06-15T08:30:00",
|
|
|
|
|
"birth_lat": 51.5074,
|
|
|
|
|
"birth_lon": -0.1278,
|
|
|
|
|
"birth_place": "London, UK",
|
|
|
|
|
"birth_tz": "Europe/London",
|
|
|
|
|
"house_system": "O",
|
|
|
|
|
"chart_data": chart_data,
|
|
|
|
|
}),
|
|
|
|
|
content_type="application/json",
|
|
|
|
|
)
|
|
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_first_save_with_chart_data_returns_stargazer_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
data = self._post().json()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertIn("note", data)
|
|
|
|
|
recog = data["note"]
|
2026-04-22 02:13:29 -04:00
|
|
|
self.assertEqual(recog["slug"], "stargazer")
|
|
|
|
|
self.assertIn("title", recog)
|
|
|
|
|
self.assertIn("description", recog)
|
|
|
|
|
self.assertIn("earned_at", recog)
|
|
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_first_save_creates_note_in_db(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
self._post()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 1)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_second_save_returns_null_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
self._post()
|
|
|
|
|
data = self._post().json()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertIsNone(data["note"])
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_second_save_does_not_create_duplicate_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
self._post()
|
|
|
|
|
self._post()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 1)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_save_with_empty_chart_data_does_not_grant_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
data = self._post(chart_data={}).json()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertIsNone(data["note"])
|
|
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 0)
|
2026-04-22 02:13:29 -04:00
|
|
|
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
def test_save_with_null_chart_data_does_not_grant_note(self):
|
2026-04-22 02:13:29 -04:00
|
|
|
data = self._post(chart_data=None).json()
|
rename: Note→Post/Line (dashboard); Recognition→Note (drama); new-post/my-posts to billboard
- dashboard: Note→Post, Item→Line across models, forms, views, API, urls & tests
- new-post (9×3) & my-posts (3×3) applets migrate from dashboard→billboard context; billboard view passes form & recent_posts
- drama: Recognition→Note, related_name notes; billboard URL /recognition/→/my-notes/, set-palette at /note/<slug>/set-palette
- recognition.js→note.js (module Note, data.note key); recognition-page.js→note-page.js; .recog-*→.note-*
- _recognition.scss→_note.scss; BillNotes page header; applet slug billboard-recognition→billboard-notes (My Notes)
- NoteSpec.js replaces RecognitionSpec.js; test_recognition.py→test_applet_my_notes.py
- 4 migrations applied: dashboard 0004, applets 0011+0012, drama 0005; 683 ITs green
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-22 22:32:34 -04:00
|
|
|
self.assertIsNone(data["note"])
|
|
|
|
|
self.assertEqual(Note.objects.filter(user=self.user, slug="stargazer").count(), 0)
|
sky.html: DEL btn at wheel center; async SAVE SKY transitions into saved state without reload; pre-save hides wheel-col so form+SAVE SKY stay centered — TDD
DEL btn (.btn-danger, "Forget sky?" data-confirm wired to the global #id_guard_portal) sits absolutely centered inside .sky-wheel-col; OK submits a POST to the new sky_delete view, which clears every sky_* field on the User model & redirects back to /dashboard/sky/.
The sky.html aperture is now uniform across saved/unsaved: form-col is always flex-column align-center justify-center so the fields + SAVE SKY pair sits visually centered. body.sky-saved adds *only* the snap-binary scroll layer (scroll-snap-type:y, modal-body display:contents, cols min-height:100% scroll-snap-align:start, wheel-col aspect-ratio cap released, form-col flex:0 0 auto so the snap basis wins) — the column-stacking is no longer gated.
Async save: SAVE SKY's success branch now calls _activateSavedState(), which adds body.sky-saved, draws the wheel from _lastChartData, pins overlay.scrollTop to the form section's offsetTop, then runs the existing _scrollApertureToTop ease-out so the wheel reveals from above instead of replacing the form with a hard cut. The wheel preview that previously redrew during typing is now gated on _savedSky — pre-first-save typing fetches the chart data (so SAVE SKY enables) but does not render the wheel, mirroring the My Sky applet's "no wheel until saved" UX. The in-room PICK SKY overlay (_sky_overlay.html) still previews live, deliberately untouched.
Pre-save the wheel-col is hidden via `body:not(.sky-saved) .sky-page .sky-wheel-col { display: none }`, so the empty SVG can't shunt the form below the fold (& the DEL btn rides the same selector since it lives inside .sky-wheel-col).
Tests: SkyDeleteTest IT class (5: clears fields, redirects, 405 on GET, login required, preserves unrelated user fields). MySkyDeleteFlowTest FT class (3: DEL btn visibility gated on sky data, NVM dismisses w. data intact, OK clears + reverts body class). MySkyAsyncSaveTest FT (1: fresh user → SAVE SKY → body picks up sky-saved, wheel SVG populates, DEL btn becomes visible — all without a page reload). All 13 sky FTs + sky ITs green; existing MySkyApertureSnapScrollTest & MySkyTimezoneRefreshTest still pass.
Code architected by Disco DeDisco <discodedisco@outlook.com>
Git commit message Co-Authored-By:
Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-08 13:07:56 -04:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class SkyDeleteTest(TestCase):
|
|
|
|
|
"""POST /dashboard/sky/delete clears all sky fields on the User model and
|
|
|
|
|
redirects back to /dashboard/sky/. The Stargazer Note is preserved (it's
|
|
|
|
|
earned, not stateful)."""
|
|
|
|
|
|
|
|
|
|
def setUp(self):
|
|
|
|
|
from datetime import datetime
|
|
|
|
|
import zoneinfo
|
|
|
|
|
|
|
|
|
|
self.user = User.objects.create(email="star@test.io")
|
|
|
|
|
self.user.sky_chart_data = {"planets": {"Sun": {"sign": "Gemini"}}}
|
|
|
|
|
self.user.sky_birth_place = "Baltimore, MD, US"
|
|
|
|
|
self.user.sky_birth_tz = "America/New_York"
|
|
|
|
|
self.user.sky_birth_lat = 39.2904
|
|
|
|
|
self.user.sky_birth_lon = -76.6122
|
|
|
|
|
self.user.sky_birth_dt = datetime(
|
|
|
|
|
1990, 6, 15, 12, 0, tzinfo=zoneinfo.ZoneInfo("UTC")
|
|
|
|
|
)
|
|
|
|
|
self.user.sky_house_system = "O"
|
|
|
|
|
self.user.save()
|
|
|
|
|
self.client.force_login(self.user)
|
|
|
|
|
self.url = reverse("sky_delete")
|
|
|
|
|
|
|
|
|
|
def test_post_clears_all_sky_fields(self):
|
|
|
|
|
self.client.post(self.url)
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertIsNone(self.user.sky_chart_data)
|
|
|
|
|
self.assertIsNone(self.user.sky_birth_dt)
|
|
|
|
|
self.assertIsNone(self.user.sky_birth_lat)
|
|
|
|
|
self.assertIsNone(self.user.sky_birth_lon)
|
|
|
|
|
self.assertEqual(self.user.sky_birth_place, "")
|
|
|
|
|
self.assertEqual(self.user.sky_birth_tz, "")
|
|
|
|
|
|
|
|
|
|
def test_post_redirects_to_sky_view(self):
|
|
|
|
|
response = self.client.post(self.url)
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertEqual(response["Location"], reverse("sky"))
|
|
|
|
|
|
|
|
|
|
def test_get_returns_405(self):
|
|
|
|
|
response = self.client.get(self.url)
|
|
|
|
|
self.assertEqual(response.status_code, 405)
|
|
|
|
|
|
|
|
|
|
def test_requires_login(self):
|
|
|
|
|
self.client.logout()
|
|
|
|
|
response = self.client.post(self.url)
|
|
|
|
|
self.assertEqual(response.status_code, 302)
|
|
|
|
|
self.assertIn("/?next=", response["Location"])
|
|
|
|
|
|
|
|
|
|
def test_post_preserves_unrelated_user_fields(self):
|
|
|
|
|
self.user.username = "stargazer-keepme"
|
|
|
|
|
self.user.save()
|
|
|
|
|
self.client.post(self.url)
|
|
|
|
|
self.user.refresh_from_db()
|
|
|
|
|
self.assertEqual(self.user.username, "stargazer-keepme")
|