|
6 | 6 |
|
7 | 7 | from ofmx2pgsql import parser |
8 | 8 |
|
| 9 | +DATA_ROOT = Path("data/ofmx_lk/isolated") |
| 10 | +OFMX_FILE = DATA_ROOT / "ofmx_lk.ofmx" |
| 11 | +SHAPES_FILE = DATA_ROOT / "ofmx_lk_ofmShapeExtension.xml" |
| 12 | +HAS_DATA = OFMX_FILE.exists() and SHAPES_FILE.exists() |
9 | 13 |
|
10 | 14 | class ParserTests(unittest.TestCase): |
| 15 | + @unittest.skipUnless(DATA_ROOT.exists(), "OFMX sample data not available") |
11 | 16 | def test_iter_ofmx_files_finds_sample(self) -> None: |
12 | | - paths = list(parser.iter_ofmx_files(Path("ofmx_lk/isolated"))) |
13 | | - self.assertEqual(paths, [Path("ofmx_lk/isolated/ofmx_lk.ofmx")]) |
| 17 | + paths = list(parser.iter_ofmx_files(DATA_ROOT)) |
| 18 | + self.assertEqual(paths, [OFMX_FILE]) |
14 | 19 |
|
| 20 | + @unittest.skipUnless(HAS_DATA, "OFMX sample data not available") |
15 | 21 | def test_iter_airports_reads_first_airport(self) -> None: |
16 | | - airports = parser.iter_airports(Path("ofmx_lk/isolated/ofmx_lk.ofmx")) |
| 22 | + airports = parser.iter_airports(OFMX_FILE) |
17 | 23 | first = next(airports) |
18 | 24 | self.assertEqual(first.code_id, "LKCB") |
19 | 25 | self.assertEqual(first.name, "CHEB") |
20 | 26 |
|
| 27 | + @unittest.skipUnless(HAS_DATA, "OFMX sample data not available") |
21 | 28 | def test_iter_waypoints_reads_first_point(self) -> None: |
22 | | - waypoints = parser.iter_waypoints(Path("ofmx_lk/isolated/ofmx_lk.ofmx")) |
| 29 | + waypoints = parser.iter_waypoints(OFMX_FILE) |
23 | 30 | first = next(waypoints) |
24 | 31 | self.assertEqual(first.code_id, "ENITA") |
25 | 32 |
|
| 33 | + @unittest.skipUnless(HAS_DATA, "OFMX sample data not available") |
26 | 34 | def test_iter_navaids_reads_first_vor(self) -> None: |
27 | | - navaids = parser.iter_navaids(Path("ofmx_lk/isolated/ofmx_lk.ofmx")) |
| 35 | + navaids = parser.iter_navaids(OFMX_FILE) |
28 | 36 | first = next(navaids) |
29 | 37 | self.assertEqual(first.navaid_type, "VOR") |
30 | 38 | self.assertEqual(first.code_id, "OKG") |
31 | 39 |
|
| 40 | + @unittest.skipUnless(HAS_DATA, "OFMX sample data not available") |
32 | 41 | def test_iter_airspace_shapes_reads_sample(self) -> None: |
33 | | - shapes = parser.iter_airspace_shapes( |
34 | | - Path("ofmx_lk/isolated/ofmx_lk_ofmShapeExtension.xml") |
35 | | - ) |
| 42 | + shapes = parser.iter_airspace_shapes(SHAPES_FILE) |
36 | 43 | first = next(shapes) |
37 | 44 | self.assertIsNotNone(first.ofmx_id) |
38 | 45 | self.assertGreater(len(first.positions), 3) |
|
0 commit comments