-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtests.py
49 lines (28 loc) · 1.16 KB
/
tests.py
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
41
42
43
44
45
46
47
48
49
import StringIO
import unittest
from command_parser import ParserResult
class FakeFileWrapper:
"""File like object."""
def __init__(self, text):
self.text = text
def open(self):
return StringIO.StringIO(self.text).getvalue().split()
class TestParserResult(unittest.TestCase):
# def setUp(self):
# self.parser_result = ParserResult()
def test_create_parser_result(self):
fake_file = FakeFileWrapper ('Lorem ipsum dolor sit amet, consectetur adipisicing elit')
parser_result = ParserResult(input_file=fake_file.open())
def test_sort_file_with_one_line(self):
fake_file = FakeFileWrapper('One two, three, for, eleven')
parser_result = ParserResult(fake_file.open())
self.assertEqual(['eleven ', 'for ', 'One ', 'three ', 'two '], parser_result.sort_file())
def test_sort_file_with_two_lines(self):
fake_file = FakeFileWrapper('One two, three, for,\n eleven, five, ana')
parser_result = ParserResult(fake_file.open())
self.assertEqual(['ana ', 'eleven ', 'five ', 'for ', 'One ', 'three ', 'two ' ], parser_result.sort_file())
@unittest.skip('WIP')
def test_if_return_list_sorted(self):
pass
if __name__ == '__main__':
unittest.main()