Revision a44a9d97 kamaki/cli/test.py

b/kamaki/cli/test.py
75 75
        self.assertEqual(history.get(), [])
76 76

  
77 77
        sample_history = (
78
            'kamaki history show\n',
79
            'kamaki file list\n',
80
            'kamaki touch pithos:f1\n',
81
            'kamaki file info pithos:f1\n')
78
            u'kamaki history show\n',
79
            u'kamaki file list\n',
80
            u'kamaki touch pithos:f1\n',
81
            u'kamaki file info pithos:f1\n')
82 82
        self.file.write(''.join(sample_history))
83 83
        self.file.flush()
84 84

  
85
        expected = ['%s.  \t%s' % (
85
        expected = [u'%s.\t%s' % (
86 86
            i + 1, event) for i, event in enumerate(sample_history)]
87 87
        self.assertEqual(history.get(), expected)
88 88
        self.assertEqual(history.get('kamaki'), expected)
......
119 119
        sample_history = (
120 120
            'kamaki history show\n',
121 121
            'kamaki file list\n',
122
            'kamaki touch pithos:f1\n',
123
            'kamaki file info pithos:f1\n',
124
            'current / last command is always excluded')
122
            'kamaki file create /pithos/f1\n',
123
            'kamaki file info /pithos/f1\n',
124
            'last command is always excluded')
125 125
        self.file.write(''.join(sample_history))
126 126
        self.file.flush()
127 127

  
128 128
        history = self.HCLASS(self.file.name)
129
        retrieve = history.__getitem__
130
        self.assertRaises(ValueError, retrieve, 'must be number')
131
        self.assertRaises(TypeError, retrieve, [1, 2, 3])
129
        self.assertRaises(ValueError, history.retrieve, 'must be number')
130
        self.assertRaises(TypeError, history.retrieve, [1, 2, 3])
132 131

  
133
        for i in (0, len(sample_history), -len(sample_history)):
134
            self.assertEqual(history[i], None)
132
        for i in (0, len(sample_history) + 1, - len(sample_history) - 1):
133
            self.assertEqual(history.retrieve(i), None)
135 134
        for i in range(1, len(sample_history)):
136
            self.assertEqual(history[i], sample_history[i - 1])
137
            self.assertEqual(history[- i], sample_history[- i - 1])
135
            self.assertEqual(history.retrieve(i), sample_history[i - 1])
136
            self.assertEqual(history.retrieve(- i), sample_history[- i])
138 137

  
139 138

  
140 139
class LoggerMethods(TestCase):

Also available in: Unified diff