nightwave / tests /test_content.py
ratandeep's picture
Feature pack: local weather, song @handle recs, DJ Sam Dusk, caller intro + tap-to-talk
a13f875 verified
Raw
History Blame Contribute Delete
1.78 kB
"""Integrity checks for the station content banks (space/content.py)."""
import os
import sys
sys.path.insert(0, os.path.join(os.path.dirname(__file__), ".."))
import content
import arc # noqa: E402
def test_song_recs_well_formed():
have = 0
for s in content.SONGS:
rb = s.get("recommended_by", "")
if rb:
have += 1
assert rb.startswith("@") and " " not in rb, rb
assert have >= 8, "expected a healthy fraction of songs to carry a request"
def test_rejoins_name_the_dj():
assert content.REJOINS
for line in content.REJOINS:
assert arc.DJ_NAME in line, line
def test_caller_intros_nonempty():
assert content.CALLER_INTROS
for line in content.CALLER_INTROS:
assert isinstance(line, str) and len(line) > 10
def test_songs_have_required_fields_and_valid_enums():
assert len(content.SONGS) >= 24
pairs = set()
for s in content.SONGS:
for k in ("title", "artist", "vibe", "key", "scale", "tempo", "timbre"):
assert k in s and s[k] != "", "song missing %s: %r" % (k, s)
assert s["key"] in (
"C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B"
), s["key"]
assert s["scale"] in content.SCALES, s["scale"]
assert s["timbre"] in content.TIMBRES, s["timbre"]
assert 50 <= int(s["tempo"]) <= 100, s["tempo"]
pairs.add((s["title"], s["artist"]))
assert len(pairs) == len(content.SONGS), "duplicate title/artist pair"
def test_other_banks_nonempty_and_shaped():
assert content.STATION_IDS and content.WEATHER and content.DEDICATIONS
assert isinstance(content.SONIC_LOGO, str) and content.SONIC_LOGO
for d in content.DEDICATIONS:
assert "name" in d and "message" in d