Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions tests/test_validate_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import copy
import sys
import tempfile
import unittest
from pathlib import Path

Expand All @@ -26,6 +27,23 @@ def setUp(self) -> None:
def errors_for(self, registry=None, experiments=None):
return validate(registry or self.registry, experiments or self.experiments)


def test_load_json_raises_value_error_on_non_object(self):
with tempfile.TemporaryDirectory() as tmpdir:
path = Path(tmpdir) / "test.json"

# Test with list
path.write_text('["array"]')
with self.assertRaises(ValueError) as context:
load_json(path)
self.assertIn("top-level value must be an object", str(context.exception))

# Test with string
path.write_text('"string"')
with self.assertRaises(ValueError) as context:
load_json(path)
self.assertIn("top-level value must be an object", str(context.exception))

def test_authoritative_registries_are_valid(self):
self.assertEqual(self.errors_for(), [])

Expand Down
Loading