aboutsummaryrefslogtreecommitdiff
path: root/tests/test_imagoIO.py
blob: c3c6fdab3449ea759a44af1e1ec1575c29edfc69 (plain)
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
"""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()