diff options
author | InigoGutierrez <inigogf.95@gmail.com> | 2022-12-14 15:41:49 +0100 |
---|---|---|
committer | InigoGutierrez <inigogf.95@gmail.com> | 2022-12-14 15:41:49 +0100 |
commit | 824d5e3b6954407a694f5739cbeb40f66324c8d7 (patch) | |
tree | 2edd317df4a83afbb305e017f3d5afd92b6b5422 /tests/test_imagoIO.py | |
parent | e8b9bf589e698b51e55ae59693b5bb0293f86a26 (diff) | |
download | imago-824d5e3b6954407a694f5739cbeb40f66324c8d7.tar.gz imago-824d5e3b6954407a694f5739cbeb40f66324c8d7.zip |
Developing Unit Testing.
Diffstat (limited to 'tests/test_imagoIO.py')
-rw-r--r-- | tests/test_imagoIO.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/test_imagoIO.py b/tests/test_imagoIO.py new file mode 100644 index 0000000..c3c6fda --- /dev/null +++ b/tests/test_imagoIO.py @@ -0,0 +1,40 @@ +"""Tests for the input/output component.""" + +import unittest + +import io +import sys + +from imago.engine.imagoIO import ImagoIO + +class TestImagoIO(unittest.TestCase): + """Test ImagoIO component.""" + + @unittest.mock.patch('imago.engine.imagoIO.input', create=True) + + def testSimpleCommands(self, mocked_input): + """Test simple commands.""" + + mocked_input.side_effect = [ + 'name\n', + 'version\n', + 'protocol_version\n', + 'quit\n' + ] + + testout = io.StringIO() + imagoIO = ImagoIO(outputStream=testout) + + imagoIO.start() + value = testout.getvalue() + self.assertEqual( + '= Imago\n\n' + + '= 0.0.0\n\n' + + '= 2\n\n', + value + ) + + testout.close() + +if __name__ == '__main__': + unittest.main() |