Revision 46fbdd04 test/ganeti.cli_unittest.py

b/test/ganeti.cli_unittest.py
22 22
"""Script for unittesting the cli module"""
23 23

  
24 24
import unittest
25
from cStringIO import StringIO
25 26

  
26 27
import ganeti
27 28
import testutils
......
75 76
                            "option", data)
76 77

  
77 78

  
79
class TestToStream(unittest.TestCase):
80
  """Thes the ToStream functions"""
81

  
82
  def testBasic(self):
83
    for data in ["foo",
84
                 "foo %s",
85
                 "foo %(test)s",
86
                 "foo %s %s",
87
                 "",
88
                 ]:
89
      buf = StringIO()
90
      cli._ToStream(buf, data)
91
      self.failUnlessEqual(buf.getvalue(), data+'\n')
92

  
93
  def testParams(self):
94
      buf = StringIO()
95
      cli._ToStream(buf, "foo %s", 1)
96
      self.failUnlessEqual(buf.getvalue(), "foo 1\n")
97
      buf = StringIO()
98
      cli._ToStream(buf, "foo %s", (15,16))
99
      self.failUnlessEqual(buf.getvalue(), "foo (15, 16)\n")
100
      buf = StringIO()
101
      cli._ToStream(buf, "foo %s %s", "a", "b")
102
      self.failUnlessEqual(buf.getvalue(), "foo a b\n")
103

  
78 104
if __name__ == '__main__':
79 105
  unittest.main()

Also available in: Unified diff