Skip to content

Commit

Permalink
Added test for errors
Browse files Browse the repository at this point in the history
  • Loading branch information
coretl committed Jun 2, 2016
1 parent e878e8a commit 8e0d770
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions tests/test_core/test_process.py
@@ -1,7 +1,6 @@
import unittest
import sys
import os
import time
import logging
logging.basicConfig()
sys.path.append(os.path.join(os.path.dirname(__file__), "..", ".."))
Expand All @@ -16,7 +15,7 @@
from malcolm.core.scheduler import Scheduler


class TestBlock(unittest.TestCase):
class TestProcess(unittest.TestCase):

def test_init(self):
s = MagicMock()
Expand All @@ -39,5 +38,18 @@ def test_starting_process(self):
p.stop()
b.handle_request.assert_called_once_with(request)

def test_error(self):
s = Scheduler("sched")
p = Process("proc", s)
p.log_exception = MagicMock()
p.start()
request = MagicMock()
request.endpoint = ["anything"]
request.to_dict.return_value = "<to_dict>"
p.q.put(request)
p.stop()
p.log_exception.assert_called_once_with("Exception while handling %s",
"<to_dict>")

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

0 comments on commit 8e0d770

Please sign in to comment.