| from midnight_static.fixtures import fixture_script | |
| from midnight_static.schema import Genre, Line, Script | |
| def test_fixture_script_is_valid(): | |
| script = fixture_script("a phone that only receives calls from 1962") | |
| script.validate() | |
| assert script.genre == Genre.WEIRD | |
| assert len(script.cast) >= 2 | |
| assert len(script.scenes) == 2 | |
| def test_schema_rejects_unknown_cast_reference(): | |
| script = fixture_script("static") | |
| broken_scene = script.scenes[0] | |
| broken = Script( | |
| title=script.title, | |
| logline=script.logline, | |
| genre=script.genre, | |
| cast=script.cast, | |
| scenes=[ | |
| type(broken_scene)( | |
| title=broken_scene.title, | |
| sfx=broken_scene.sfx, | |
| lines=[Line(cast="missing", text="No one can say this.")], | |
| ) | |
| ], | |
| music=script.music, | |
| estimated_seconds=script.estimated_seconds, | |
| ) | |
| try: | |
| broken.validate() | |
| except ValueError as exc: | |
| assert "unknown cast" in str(exc) | |
| else: | |
| raise AssertionError("expected validation to fail") | |