Skip to content

Commit

Permalink
Implement unittest for new servweb function
Browse files Browse the repository at this point in the history
  • Loading branch information
xresende committed Apr 5, 2018
1 parent 005f36a commit b0bdb1b
Show file tree
Hide file tree
Showing 3 changed files with 1,099 additions and 5 deletions.
22 changes: 18 additions & 4 deletions siriuspy/tests/servweb/test_implementation.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def test_read_url_exception(self):
class TestServWeb(unittest.TestCase):
"""Test servweb."""

api = {
public_interface = {
'read_url',
'server_online',
'magnets_excitation_data_read',
Expand All @@ -66,6 +66,7 @@ class TestServWeb(unittest.TestCase):
'magnets_excitation_ps_read',
'ps_pstypes_names_read',
'ps_pstype_data_read',
'ps_siggen_configuration_read',
'ps_pstype_setpoint_limits',
'pu_pstype_setpoint_limits',
'ps_psmodels_read',
Expand All @@ -77,10 +78,10 @@ class TestServWeb(unittest.TestCase):
'high_level_triggers'
}

def test_api(self, mock_read):
"""Test api."""
def test_public_interface(self, mock_read):
"""Test module's public interface."""
valid = util.check_public_interface_namespace(
implementation, TestServWeb.api)
implementation, TestServWeb.public_interface)
self.assertTrue(valid)

def test_server_online(self, mock_read):
Expand Down Expand Up @@ -174,6 +175,19 @@ def test_ps_pstype_data_read(self, mock_read):
mock.call(url, timeout=1.0),
mock.call(url, timeout=2.0)])

def test_ps_siggen_configuration_read(self, mock_read):
"""Test ps_siggen_configuration_read."""
url = implementation._ps_folder + 'siggen-configuration.txt'
# Call with different parameters
resp = implementation.ps_siggen_configuration_read()
self.assertEqual(resp, "FakeResponse")
resp = implementation.ps_siggen_configuration_read(timeout=2.0)
self.assertEqual(resp, "FakeResponse")
# Assert read_url was called correctly
mock_read.assert_has_calls([
mock.call(url, timeout=1.0),
mock.call(url, timeout=2.0)])

def test_ps_pstype_setpoint_limits(self, mock_read):
"""Test ps_pstype_setpoint_limits."""
url = implementation._ps_folder + 'pstypes-setpoint-limits.txt'
Expand Down
Loading

0 comments on commit b0bdb1b

Please sign in to comment.