-
Notifications
You must be signed in to change notification settings - Fork 0
/
unittests.py
85 lines (70 loc) · 2.56 KB
/
unittests.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
import unittest
from keymap import KeyMap
from action import ActionContext
from model import Model
class TestSequenceFunctions(unittest.TestCase):
def setUp(self):
self.model = Model()
self.km = KeyMap()
self.ac = ActionContext(self.km, self.model, None)
def test_keymap_sequence(self):
self.km.addCommand('j')
demands = self.km.translate()
self.assertTrue(demands == 'cursor_down')
def test_down(self):
self.km.addCommand('j')
demands = self.km.translate()
self.ac.do(demands)
(x, y) = self.model.getCursor().getCursor()
self.assertTrue(x == 0 and y == 1)
def test_left(self):
self.km.addCommand('l')
demands = self.km.translate()
self.ac.do(demands)
(x, y) = self.model.getCursor().getCursor()
self.assertTrue(x == 1 and y == 0)
def test_looparound(self):
self.km.addCommand('j')
demands = self.km.translate()
self.ac.do(demands)
self.km.addCommand('l')
demands = self.km.translate()
self.ac.do(demands)
self.km.addCommand('k')
demands = self.km.translate()
self.ac.do(demands)
self.km.addCommand('h')
demands = self.km.translate()
self.ac.do(demands)
(x, y) = self.model.getCursor().getCursor()
self.assertTrue(x == 0 and y == 0)
def test_insert(self):
sample_text = "This is sample text"
sheet = self.model.getSheet()
cursor = self.model.getCursor()
cursor.setCellAtCursor(sheet, sample_text)
cell = cursor.getCell(sheet)
self.assertTrue(cell.getRawContent() == sample_text)
def test_discernText(self):
sample_text = "This is sample text"
sheet = self.model.getSheet()
cursor = self.model.getCursor()
cursor.setCellAtCursor(sheet, sample_text)
cell = cursor.getCell(sheet)
self.assertTrue(cell.getType() == "Text")
def test_discernNumeric(self):
sample_text = "3.14159"
sheet = self.model.getSheet()
cursor = self.model.getCursor()
cursor.setCellAtCursor(sheet, sample_text)
cell = cursor.getCell(sheet)
self.assertTrue(cell.getType() == "Numeric")
def test_discernFormula(self):
sample_text = "=sum(A1:A10)"
sheet = self.model.getSheet()
cursor = self.model.getCursor()
cursor.setCellAtCursor(sheet, sample_text)
cell = cursor.getCell(sheet)
self.assertTrue(cell.getType() == "Formula")
if __name__ == '__main__':
unittest.main()