-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from NTIA/updates
Add healthy check and raise exception when base_url is misconfigured
- Loading branch information
Showing
6 changed files
with
81 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import unittest | ||
import json | ||
|
||
from its_preselector.web_relay_preselector import WebRelayPreselector | ||
|
||
|
||
class MyTestCase(unittest.TestCase): | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
file = open('test_metadata.sigmf-meta') | ||
cls.sensor_def = json.load(file) | ||
file.close() | ||
|
||
def test_blank_base_url(self): | ||
preselector = WebRelayPreselector(self.sensor_def, {'base_url': '', 'antenna' : '1State=0,2State=0,3State=0,4State=0' }) | ||
with self.assertRaises(Exception): | ||
preselector.set_state('antenna') | ||
|
||
def test_none_base_url(self): | ||
preselector = WebRelayPreselector(self.sensor_def, {'base_url': None, 'antenna' : '1State=0,2State=0,3State=0,4State=0' }) | ||
with self.assertRaises(Exception): | ||
preselector.set_state('antenna') | ||
|
||
def test_invalid_base_url(self): | ||
preselector = WebRelayPreselector(self.sensor_def, {'base_url': 'http://badpreselector.gov', 'antenna' : '1State=0,2State=0,3State=0,4State=0' }) | ||
with self.assertRaises(Exception): | ||
preselector.set_state('antenna') | ||
|
||
def test_healthy_false(self): | ||
preselector = WebRelayPreselector(self.sensor_def, {'base_url': 'http://bad_preselector.gov', | ||
'antenna': '1State=0,2State=0,3State=0,4State=0'}) | ||
self.assertFalse(preselector.healthy()) | ||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters