aboutsummaryrefslogtreecommitdiff
path: root/tests/test_imagoIO.py
diff options
context:
space:
mode:
authorInigoGutierrez <inigogf.95@gmail.com>2022-12-14 15:41:49 +0100
committerInigoGutierrez <inigogf.95@gmail.com>2022-12-14 15:41:49 +0100
commit824d5e3b6954407a694f5739cbeb40f66324c8d7 (patch)
tree2edd317df4a83afbb305e017f3d5afd92b6b5422 /tests/test_imagoIO.py
parente8b9bf589e698b51e55ae59693b5bb0293f86a26 (diff)
downloadimago-824d5e3b6954407a694f5739cbeb40f66324c8d7.tar.gz
imago-824d5e3b6954407a694f5739cbeb40f66324c8d7.zip
Developing Unit Testing.
Diffstat (limited to 'tests/test_imagoIO.py')
-rw-r--r--tests/test_imagoIO.py40
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()