-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
51 lines (39 loc) · 1.6 KB
/
test.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
import unittest
import os
import shutil
from unittest.mock import patch
from laz2las import convert_laz_to_las
class TestLazToLas(unittest.TestCase):
def setUp(self):
self.test_data_dir = "test_data"
self.output_dir = "test_output"
# Create test data directory
os.makedirs(self.test_data_dir, exist_ok=True)
os.makedirs(self.output_dir, exist_ok=True)
def tearDown(self):
# Clean up test data
shutil.rmtree(self.test_data_dir)
shutil.rmtree(self.output_dir)
def test_convert_laz_to_las_success(self):
# Create a mock LAZ file
# ... (replace with actual LAZ file creation logic)
# Call the function to convert
result = convert_laz_to_las(laz_file_path, self.output_dir)
# Assert that the conversion was successful
self.assertTrue(result)
self.assertTrue(os.path.exists(output_file))
def test_convert_laz_to_las_failure(self):
# Create a mock invalid LAZ file
# ... (replace with actual invalid LAZ file creation logic)
# Call the function to convert
result = convert_laz_to_las(invalid_laz_file_path, self.output_dir)
# Assert that the conversion failed
self.assertFalse(result)
def test_output_dir_creation(self):
# Test if output directory is created if it doesn't exist
output_dir = "non_existent_dir"
result = convert_laz_to_las(laz_file_path, output_dir)
# Assert that the output directory was created
self.assertTrue(os.path.exists(output_dir))
if __name__ == '__main__':
unittest.main()