Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert CounterController to CounterPart
- Loading branch information
Showing
4 changed files
with
46 additions
and
52 deletions.
There are no files selected for viewing
6 changes: 3 additions & 3 deletions
6
malcolm/controllers/countercontroller.py → malcolm/parts/demo/counterpart.py
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 was deleted.
Oops, something went wrong.
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,37 @@ | ||
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.parts.demo import CounterPart | ||
from malcolm.core.block import Block | ||
|
||
|
||
class TestCounterPart(unittest.TestCase): | ||
|
||
def setUp(self): | ||
self.c = CounterPart(Mock(), None) | ||
list(self.c.create_attributes()) | ||
|
||
def test_increment_increments(self): | ||
self.assertEquals(0, self.c.counter.value) | ||
self.c.increment() | ||
self.assertEquals(1, self.c.counter.value) | ||
self.c.increment() | ||
self.assertEquals(2, self.c.counter.value) | ||
|
||
def test_reset_sets_zero(self): | ||
self.c.counter.set_endpoint_data("value", 1234, notify=False) | ||
self.c.do_reset() | ||
self.assertEquals(0, self.c.counter.value) | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main(verbosity=2) |