ogn-python/tests/gateway/test_manage.py

23 wiersze
616 B
Python
Czysty Zwykły widok Historia

2015-11-21 22:05:22 +00:00
import unittest
import unittest.mock as mock
from ogn.gateway.manage import run
class GatewayManagerTest(unittest.TestCase):
2015-11-21 22:05:22 +00:00
# try simple user interrupt
@mock.patch('ogn.gateway.manage.AprsClient')
def test_run_user_interruption(self, mock_aprs_client):
instance = mock_aprs_client.return_value
2015-11-21 22:05:22 +00:00
instance.run.side_effect = KeyboardInterrupt()
run(aprs_user="testuser")
2015-11-21 22:05:22 +00:00
instance.connect.assert_called_once_with()
self.assertEqual(instance.run.call_count, 1)
2015-11-21 22:05:22 +00:00
instance.disconnect.assert_called_once_with()
if __name__ == '__main__':
unittest.main()