-
Notifications
You must be signed in to change notification settings - Fork 14
/
test_countercontroller.py
44 lines (34 loc) · 1.27 KB
/
test_countercontroller.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
import setup_malcolm_paths
# logging
# import logging
# logging.basicConfig(level=logging.DEBUG)
import unittest
from mock import Mock, ANY
from malcolm.controllers.countercontroller import CounterController
from malcolm.core.block import Block
class TestCounterController(unittest.TestCase):
def test_increment_increments(self):
c = CounterController('block', Mock())
self.assertEquals(0, c.counter.value)
c.increment()
self.assertEquals(1, c.counter.value)
c.increment()
self.assertEquals(2, c.counter.value)
def test_increment_calls_on_changed(self):
c = CounterController('block', Mock())
c.increment()
self.assertEquals(1, c.counter.value)
c.process.report_changes.assert_called_once_with(
[['block', 'counter', 'value'], 1])
def test_reset_sets_zero(self):
c = CounterController('block', Mock())
c.counter.set_endpoint_data("value", 1234, notify=False)
c.do_reset()
self.assertEquals(0, c.counter.value)
c.process.report_changes.assert_called_once_with(
[['block', 'counter', 'value'], 0])
if __name__ == "__main__":
unittest.main(verbosity=2)