11import unittest
22from spritesTable import SpritesTable
33
4-
5- class DummyTable :
6- def __init__ (self , rowCount , columnCount ):
7- self .rowCount = rowCount
8- self .columnCount = columnCount
9-
10-
114class TestSpritesTable (unittest .TestCase ):
125 def testInit (self ):
13- t = SpritesTable (DummyTable ( 3 , 4 ), 1 , 5 , 13 , True )
6+ t = SpritesTable (1 , 3 , 4 , 5 , 13 , True )
147 self .assertEqual (t .tableID , 1 )
158 self .assertEqual (t .rowCount , 3 )
169 self .assertEqual (t .columnCount , 4 )
@@ -32,7 +25,7 @@ def testInit(self):
3225 self .assertFalse (t .filterColumns )
3326
3427 def testChangeRowOffset (self ):
35- t = SpritesTable (DummyTable ( 3 , 4 ), 1 , 5 , 13 , True )
28+ t = SpritesTable (1 , 3 , 4 , 5 , 13 , True )
3629 t .changeRowOffset (2 )
3730 self .assertEqual (t .currRow , 3 )
3831 t .changeRowOffset (- 1 )
@@ -42,7 +35,7 @@ def testChangeRowOffset(self):
4235 self .assertEqual (t .currRow , 1 )
4336
4437 def testChangeColumnOffset (self ):
45- t = SpritesTable (DummyTable ( 3 , 4 ), 1 , 5 , 13 , True )
38+ t = SpritesTable (1 , 3 , 4 , 5 , 13 , True )
4639 t .changeColumnOffset (3 )
4740 self .assertEqual (t .currColumn , 4 )
4841 t .changeColumnOffset (- 1 )
@@ -52,7 +45,7 @@ def testChangeColumnOffset(self):
5245 self .assertEqual (t .currColumn , 1 )
5346
5447 def testScrollRowsRegular (self ):
55- t = SpritesTable (DummyTable ( 6 , 4 ), 1 , 5 , 13 , True )
48+ t = SpritesTable (1 , 6 , 4 , 5 , 13 , True )
5649 # cannot scroll to previous at start
5750 self .assertFalse (t .scroll (direction = 0 , keyIdx = 0 ))
5851 self .assertTrue (t .scroll (direction = 0 , keyIdx = 4 ))
@@ -66,7 +59,7 @@ def testScrollRowsRegular(self):
6659
6760 def testScrollRowsEdge (self ):
6861 # test table with 10 rows
69- t = SpritesTable (DummyTable ( 10 , 4 ), 1 , 5 , 13 , True )
62+ t = SpritesTable (1 , 10 , 4 , 5 , 13 , True )
7063 # cannot scroll to previous at start
7164 self .assertFalse (t .scroll (direction = 0 , keyIdx = 0 ))
7265 self .assertTrue (t .scroll (direction = 0 , keyIdx = 4 ))
@@ -80,7 +73,7 @@ def testScrollRowsEdge(self):
8073
8174 def testScrollColumnsRegular (self ):
8275 # assume 3 keys for navigate columns
83- t = SpritesTable (DummyTable ( 6 , 4 ), 1 , 5 , 3 , True )
76+ t = SpritesTable (1 , 6 , 4 , 5 , 3 , True )
8477 # cannot scroll to previous at start
8578 self .assertFalse (t .scroll (direction = 1 , keyIdx = 0 ))
8679 self .assertTrue (t .scroll (direction = 1 , keyIdx = 2 ))
@@ -94,7 +87,7 @@ def testScrollColumnsRegular(self):
9487
9588 def testScrollColumnsEdge (self ):
9689 # test table with 6 columns
97- t = SpritesTable (DummyTable ( 6 , 6 ), 1 , 5 , 3 , True )
90+ t = SpritesTable (1 , 6 , 6 , 5 , 3 , True )
9891 # cannot scroll to previous at start
9992 self .assertFalse (t .scroll (direction = 1 , keyIdx = 0 ))
10093 self .assertTrue (t .scroll (direction = 1 , keyIdx = 2 ))
@@ -107,7 +100,7 @@ def testScrollColumnsEdge(self):
107100 self .assertFalse (t .scroll (direction = 1 , keyIdx = 0 ))
108101
109102 def testNextResult (self ):
110- t = SpritesTable (DummyTable ( 4 , 5 ), 1 , 5 , 13 , True )
103+ t = SpritesTable (1 , 4 , 5 , 5 , 13 , True )
111104 t .searchResults = [(1 , 1 ), (2 , 3 ), (3 , 3 ), (3 , 4 ), (3 , 5 )]
112105 # go through all results using next
113106 self .assertTrue (t .nextResult ())
@@ -129,7 +122,7 @@ def testNextResult(self):
129122 self .assertEqual (t .getMappedColumns (), [5 ])
130123
131124 def testPrevResult (self ):
132- t = SpritesTable (DummyTable ( 4 , 5 ), 1 , 5 , 13 , True )
125+ t = SpritesTable (1 , 4 , 5 , 5 , 13 , True )
133126 t .searchResults = [(1 , 1 ), (2 , 3 ), (3 , 3 ), (3 , 4 ), (3 , 5 )]
134127 t .resultIdx = 4
135128 t .onSearchResult = True
@@ -154,7 +147,7 @@ def testPrevResult(self):
154147 self .assertEqual (t .getCurrPosition (), (1 , 1 ))
155148
156149 def testGetOccurrences (self ):
157- t = SpritesTable (DummyTable ( 4 , 5 ), 1 , 5 , 13 , True )
150+ t = SpritesTable (1 , 4 , 5 , 5 , 13 , True )
158151 t .searchResults = [(1 , 1 ), (2 , 3 ), (3 , 3 ), (3 , 4 ), (3 , 5 )]
159152 # start off at (1, 1)
160153 self .assertEqual (t .getOccurrences (), (0 , 0 ))
@@ -172,7 +165,7 @@ def testGetOccurrences(self):
172165 self .assertEqual (t .getOccurrences (), (0 , 0 ))
173166
174167 def testFilters (self ):
175- t = SpritesTable (DummyTable ( 4 , 5 ), 1 , 5 , 13 , True )
168+ t = SpritesTable (1 , 4 , 5 , 5 , 13 , True )
176169 t .searchResults = [(1 , 1 ), (2 , 3 ), (3 , 3 ), (3 , 4 ), (3 , 5 )]
177170 t .filterRows = True
178171 t .checkAndApplyFilters ()
@@ -195,7 +188,7 @@ def testFilters(self):
195188 self .assertEqual (t .columns , [1 , 2 , 3 , 4 , 5 ])
196189
197190 def testExpandTable (self ):
198- t = SpritesTable (DummyTable ( 8 , 10 ), 1 , 5 , 4 , True )
191+ t = SpritesTable (1 , 8 , 10 , 5 , 4 , True )
199192 t .searchResults = [(2 , 2 ), (4 , 7 ), (6 , 3 )]
200193 t .filterRows = True
201194 t .resultIdx = 0
0 commit comments