Coverage for tests/test_schema_v1_fixtures.py: 38%

22 statements  

« prev     ^ index     » next       coverage.py v7.14.1, created at 2026-06-03 08:08 +0000

1# This file is part of lsst-images. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# Use of this source code is governed by a 3-clause BSD-style 

10# license that can be found in the LICENSE file. 

11 

12from __future__ import annotations 

13 

14import json 

15import unittest 

16from pathlib import Path 

17 

18SCHEMA_DIR = Path(__file__).parent / "data" / "schema_v1" 

19 

20# Every committed top-level fixture; the ``legacy/`` subdirectory (derived 

21# from real files) is exercised separately by test_schema_v1_legacy_fixtures. 

22_FIXTURES = sorted(SCHEMA_DIR.glob("*.json")) 

23 

24 

25class SchemaV1FixturesTestCase(unittest.TestCase): 

26 """Tests over the bundled v1 reference JSON fixtures.""" 

27 

28 def test_fixtures_present(self): 

29 """The fixture directory is populated.""" 

30 self.assertTrue(_FIXTURES, f"no fixtures found in {SCHEMA_DIR}") 

31 

32 def test_fixture_has_top_level_stamps(self): 

33 """Every fixture has schema_url, schema_version, min_read_version.""" 

34 for path in _FIXTURES: 

35 with self.subTest(name=path.stem): 

36 tree = json.loads(path.read_text()) 

37 self.assertIn("schema_url", tree) 

38 self.assertIn("schema_version", tree) 

39 self.assertIn("min_read_version", tree) 

40 

41 def test_fixture_url_matches_name_and_version(self): 

42 """schema_url matches the ``<name>-<version>`` pattern, where the name 

43 is the fixture file's stem. 

44 """ 

45 for path in _FIXTURES: 

46 with self.subTest(name=path.stem): 

47 tree = json.loads(path.read_text()) 

48 expected = f"https://images.lsst.io/schemas/{path.stem}-{tree['schema_version']}" 

49 self.assertEqual(tree["schema_url"], expected) 

50 

51 

52if __name__ == "__main__": 

53 unittest.main()