Skip to content

Commit

Permalink
run fixes for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
osundwajeff committed Sep 16, 2024
1 parent f04449d commit 738649c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 65 deletions.
22 changes: 1 addition & 21 deletions test/test_create_grids.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,7 @@


class TestGridCreator(unittest.TestCase):

@classmethod
def setUpClass(cls):
"""Sets up the QGIS environment before all tests."""
cls.qgs = QgsApplication([], False)
cls.qgs.initQgis()
Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())

@classmethod
def tearDownClass(cls):
"""Cleans up the QGIS environment after all tests."""
cls.qgs.exitQgis()
"""Test the GridCreator class."""

def setUp(self):
# Setup parameters for the GridCreator class
Expand Down Expand Up @@ -61,14 +49,6 @@ def test_create_grids(self):
"Merged grid output file does not exist",
)

def tearDown(self):
# Clean up after tests by removing the output directory and its contents
if os.path.exists(self.merged_output_path):
os.remove(self.merged_output_path)

if os.path.exists(self.output_dir) and not os.listdir(self.output_dir):
os.rmdir(self.output_dir)


if __name__ == "__main__":
unittest.main()
18 changes: 1 addition & 17 deletions test/test_extents.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,7 @@


class TestExtents(unittest.TestCase):

@classmethod
def setUpClass(cls):
"""Sets up the QGIS environment before all tests."""
cls.qgs = QgsApplication([], False)
cls.qgs.initQgis()
Processing.initialize()
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())

@classmethod
def tearDownClass(cls):
"""Cleans up the QGIS environment after all tests."""
cls.qgs.exitQgis()
"""Test the Extents class."""

def setUp(self):
# Setup parameters for the Extents class
Expand Down Expand Up @@ -51,10 +39,6 @@ def test_get_extent(self):
country_extent.height(), 0, "Extent height is not greater than zero"
)

def tearDown(self):
# No cleanup required for Extents tests
pass


if __name__ == "__main__":
unittest.main()
28 changes: 1 addition & 27 deletions test/test_rasterizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,7 @@


class TestRasterizer(unittest.TestCase):

@classmethod
def setUpClass(cls):
"""Sets up the QGIS environment before all tests."""
# Start a QGIS application instance for testing
cls.qgs = QgsApplication([], False)
cls.qgs.initQgis()

# Initialize processing
Processing.initialize()

# Add native algorithms for testing (this is important for running processing algorithms)
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())

@classmethod
def tearDownClass(cls):
"""Cleans up the QGIS environment after all tests."""
cls.qgs.exitQgis()
"""Test the Rasterizer class."""

def setUp(self):
# Setup real parameters for the Rasterizer class
Expand Down Expand Up @@ -70,15 +53,6 @@ def test_rasterize_vector_layer(self):
os.path.exists(rasterized_output), "Rasterized output file does not exist"
)

def tearDown(self):
# Clean up after tests by removing the output directory and its contents
rasterized_output = os.path.join(self.output_dir, "rasterized_output.tif")
if os.path.exists(rasterized_output):
os.remove(rasterized_output)

if os.path.exists(self.output_dir) and not os.listdir(self.output_dir):
os.rmdir(self.output_dir)


if __name__ == "__main__":
unittest.main()

0 comments on commit 738649c

Please sign in to comment.