Skip to content

Commit

Permalink
Adds unit test for catching SDKs not installed
Browse files Browse the repository at this point in the history
Adding test to make coverage not complain, and to
also validate that if the environment variables are present
that things wont break if the right SDK is not installed.
  • Loading branch information
skrawcz committed May 4, 2024
1 parent e54cb27 commit 18edb9c
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/test_driver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import os
import unittest
from unittest.mock import patch

from naturf import driver


class TestDriverGuardAgainstSDK(unittest.TestCase):
INPUTS = {
"input_shapefile": os.path.join("naturf", "data", "C-5.shp"),
"radius": 100,
"cap_style": 1,
}

# mock the driver module variables
@patch("naturf.driver.HAMILTON_UI_PROJECT_ID", "3")
@patch("naturf.driver.HAMILTON_UI_USERNAME", "test@test")
def tests_sdk_not_installed(self):
"""tests that things work if the sdk is not installed"""
# this line running without error means that our checks worked
driver.Model(inputs=TestDriverGuardAgainstSDK.INPUTS, outputs=["input_shapefile_df"])

@patch("naturf.driver.HAMILTON_UI_PROJECT_ID", "3")
@patch("naturf.driver.HAMILTON_UI_USERNAME", "test@test")
@patch("naturf.driver.DAGWORKS_API_KEY", "some-api-key")
def tests_sdk_not_installed_DW(self):
"""tests that things work if the sdk is not installed for the DW path"""
# this line running without error means that our checks worked
driver.Model(inputs=TestDriverGuardAgainstSDK.INPUTS, outputs=["input_shapefile_df"])


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

0 comments on commit 18edb9c

Please sign in to comment.