-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathtest_compat_bag15.py
52 lines (34 loc) · 1.42 KB
/
test_compat_bag15.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import unittest
from pathlib import Path
import tempfile
import shutil
import logging
import bagPy as BAG
logger = logging.getLogger(__file__)
class TestCompatBAG15(unittest.TestCase):
def setUp(self) -> None:
self.datapath: Path = Path(Path(__file__).parent.parent, 'examples', 'sample-data')
self.tmp_dir = tempfile.mkdtemp()
logger.info(f"tmp_dir: {self.tmp_dir}")
def tearDown(self) -> None:
shutil.rmtree(self.tmp_dir)
def test_open_read_only(self) -> None:
bag_filename = str(Path(self.datapath, 'sample-1.5.0.bag'))
dataset = BAG.Dataset.openDataset(bag_filename, BAG.BAG_OPEN_READONLY)
self.assertIsNotNone(dataset)
kNumExpectedLayers = 4
numLayerTypes = len(dataset.getLayerTypes())
self.assertEqual(numLayerTypes, kNumExpectedLayers)
bag_elev = dataset.getLayer(BAG.Elevation)
self.assertIsNotNone(bag_elev)
dataset.close()
def test_open_read_write(self):
bag_filename = str(Path(self.datapath, 'sample-1.5.0.bag'))
dataset = BAG.Dataset.openDataset(bag_filename, BAG.BAG_OPEN_READ_WRITE)
self.assertIsNotNone(dataset)
kNumExpectedLayers = 4
numLayerTypes = len(dataset.getLayerTypes())
self.assertEqual(numLayerTypes, kNumExpectedLayers)
bag_elev = dataset.getLayer(BAG.Elevation)
self.assertIsNotNone(bag_elev)
dataset.close()