49 |
def testGetConnections(): |
def testGetConnections(): |
50 |
n[6].addProperty(p, n[1]) |
n[6].addProperty(p, n[1]) |
51 |
|
|
52 |
c.set(n[0], n[1]) |
c.set(n[0], 1, n[1]) |
53 |
assert list(c.getConnections(1)) == [n[1]] |
assert list(c.getConnections(1)) == [n[1]] |
54 |
assert list(c.getConnections(-1)) == [] |
assert list(c.getConnections(-1)) == [] |
55 |
|
|
56 |
c.set(n[1], n[2]) |
c.set(n[1], 1, n[2]) |
57 |
assert list(c.getConnections(1)) == [n[2]] |
assert list(c.getConnections(1)) == [n[2]] |
58 |
assert list(c.getConnections(-1)) == [n[0], n[6]] |
assert list(c.getConnections(-1)) == [n[0], n[6]] |
59 |
|
|
60 |
c.set(n[2], n[3]) |
c.set(n[2], 1, n[3]) |
61 |
assert list(c.getConnections(1)) == n[3:] |
assert list(c.getConnections(1)) == n[3:] |
62 |
assert list(c.getConnections(-1)) == [n[1]] |
assert list(c.getConnections(-1)) == [n[1]] |
63 |
|
|
64 |
c.set(n[6], n[1]) |
c.set(n[6], 1, n[1]) |
65 |
assert list(c.getConnections(1)) == [n[1]] |
assert list(c.getConnections(1)) == [n[1]] |
66 |
assert list(c.getConnections(-1)) == [n[2]] |
assert list(c.getConnections(-1)) == [n[2]] |
67 |
|
|
68 |
|
|
69 |
def testConnectedTwoWays(): |
def testConnectedTwoWays(): |
|
""" |
|
|
fail: * |
|
|
""" |
|
70 |
n[5].addProperty(p, n[0]) |
n[5].addProperty(p, n[0]) |
71 |
n[5].addProperty(p, n[2]) |
n[5].addProperty(p, n[2]) |
72 |
|
|
73 |
c.set(n[2], n[5]) |
c.set(n[2], 1, n[5]) |
74 |
c.move(1) |
c.move(1) |
75 |
assert c.getRotationIndex() == 0 |
assert c.getRotationIndex() == 0 |
76 |
|
|
79 |
|
|
80 |
|
|
81 |
def testRotationIndex(): |
def testRotationIndex(): |
82 |
c.set(n[1], n[2]) |
c.set(n[1], 1, n[2]) |
83 |
assert c.getRotationIndex() == 0 |
assert c.getRotationIndex() == 0 |
84 |
|
|
85 |
c.set(n[2], n[5]) |
c.set(n[2], 1, n[5]) |
86 |
assert c.getRotationIndex() == 2 |
assert c.getRotationIndex() == 2 |
87 |
|
|
88 |
c.set(n[2], n[9]) |
c.set(n[2], 1, n[9]) |
89 |
assert c.getRotationIndex() == 6 |
assert c.getRotationIndex() == 6 |
90 |
|
|
91 |
c.set(n[4], None) |
c.set(n[4], 0, None) |
92 |
assert c.getRotationIndex() == 0 |
assert c.getRotationIndex() == 0 |
93 |
|
|
94 |
|
|
96 |
n[4].addProperty(p, n[5]) |
n[4].addProperty(p, n[5]) |
97 |
n[6].addProperty(p, n[5]) |
n[6].addProperty(p, n[5]) |
98 |
|
|
99 |
c.set(n[5], n[4]) |
c.set(n[5], -1, n[4]) |
100 |
|
|
101 |
assert c.getRotationIndex() == 1 |
assert c.getRotationIndex() == 1 |
102 |
c.rotate(-1) |
c.rotate(-1) |
112 |
assert c.getRotationIndex() == 2 |
assert c.getRotationIndex() == 2 |
113 |
assert c.rotation == n[6] |
assert c.rotation == n[6] |
114 |
|
|
115 |
c.set(n[5], None) |
c.set(n[5], 0, None) |
116 |
|
|
117 |
assert c.getRotationIndex() == 0 |
assert c.getRotationIndex() == 0 |
118 |
c.rotate(-1) |
c.rotate(-1) |
121 |
assert c.getRotationIndex() == 1 |
assert c.getRotationIndex() == 1 |
122 |
assert c.rotation == n[4] |
assert c.rotation == n[4] |
123 |
|
|
124 |
c.set(n[5], None) |
c.set(n[5], 0, None) |
125 |
c.rotate(1) |
c.rotate(1) |
126 |
assert c.getRotationIndex() == 1 |
assert c.getRotationIndex() == 1 |
127 |
assert c.rotation == n[4] |
assert c.rotation == n[4] |
131 |
|
|
132 |
|
|
133 |
def testRotateMove(): |
def testRotateMove(): |
134 |
c.set(n[2], n[5]) |
c.set(n[2], 1, n[5]) |
135 |
c.rotate(1) |
c.rotate(1) |
136 |
assert c.focus == n[2] and c.rotation == n[6] |
assert c.focus == n[2] and c.rotation == n[6] and c.dir == 1 |
137 |
c.rotate(1) |
c.rotate(1) |
138 |
assert c.focus == n[2] and c.rotation == n[7] |
assert c.focus == n[2] and c.rotation == n[7] and c.dir == 1 |
139 |
c.rotate(-1) |
c.rotate(-1) |
140 |
assert c.focus == n[2] and c.rotation == n[6] |
assert c.focus == n[2] and c.rotation == n[6] and c.dir == 1 |
141 |
|
|
142 |
c.set(n[2], n[9]) |
c.set(n[2], 1, n[9]) |
143 |
c.rotate(1) |
c.rotate(1) |
144 |
assert c.focus == n[2] and c.rotation == n[9] |
assert c.focus == n[2] and c.rotation == n[9] |
145 |
c.rotate(-1) |
c.rotate(-1) |
149 |
c.rotate(1) |
c.rotate(1) |
150 |
assert c.focus == n[2] and c.rotation == n[9] |
assert c.focus == n[2] and c.rotation == n[9] |
151 |
|
|
152 |
c.set(n[2], n[1]) |
c.set(n[2], -1, n[1]) |
153 |
assert c.getRotationIndex() == 0 |
assert c.getRotationIndex() == 0 and c.dir == -1 |
154 |
c.rotate(1) |
c.rotate(1) |
155 |
assert c.getRotationIndex() == 1 |
assert c.getRotationIndex() == 1 and c.dir == 1 |
156 |
c.rotate(1) |
c.rotate(1) |
157 |
assert c.getRotationIndex() == 2 |
assert c.getRotationIndex() == 2 and c.dir == 1 |
158 |
|
c.move(-1) |
159 |
|
assert c.focus == n[2] and c.getRotationIndex() == 2 and \ |
160 |
|
c.dir == 1 |
161 |
c.move(1) |
c.move(1) |
162 |
assert c.focus == n[5] and c.rotation == n[2] |
assert c.focus == n[5] and c.rotation == n[2] and c.dir == -1 |
163 |
|
|
164 |
c.set(n[2], n[3]) |
c.set(n[2], 1, n[3]) |
165 |
c.rotate(-1) |
c.rotate(-1) |
166 |
assert c.focus == n[2] and c.rotation == n[3] |
assert c.focus == n[2] and c.rotation == n[3] and c.dir == 1 |
167 |
|
|
168 |
c.move(-1) |
c.move(-1) |
169 |
assert c.focus == n[1] and c.rotation == n[2] |
assert c.focus == n[1] and c.rotation == n[2] and c.dir == 1 |
170 |
c.move(-1) |
c.move(-1) |
171 |
assert c.focus == n[0] and c.rotation == n[1] |
assert c.focus == n[0] and c.rotation == n[1] and c.dir == 1 |
172 |
c.move(1) |
c.move(1) |
173 |
assert c.focus == n[1] and c.rotation == n[0] |
assert c.focus == n[1] and c.rotation == n[0] and c.dir == -1 |
174 |
c.move(1) |
c.move(1) |
175 |
assert c.focus == n[2] and c.rotation == n[1] |
assert c.focus == n[2] and c.rotation == n[1] and c.dir == -1 |
176 |
|
|
177 |
|
|
178 |
# if we cannot move there, we remain where we are: |
# if we cannot move there, we remain where we are: |
179 |
|
|
180 |
c.set(n[2], n[7]) |
c.set(n[2], 1, n[7]) |
181 |
c.move(-1) |
c.move(-1) |
182 |
assert c.focus == n[2] and c.rotation == n[7] |
assert c.focus == n[2] and c.rotation == n[7] and c.dir == 1 |
183 |
|
|
184 |
c.set(n[0], n[1]) |
c.set(n[0], 1, n[1]) |
185 |
c.move(-1) |
c.move(-1) |
186 |
assert c.focus == n[0] and c.rotation == n[1] |
assert c.focus == n[0] and c.rotation == n[1] and c.dir == 1 |
187 |
|
|
188 |
|
|
189 |
|
def testRotationChangesDir(): |
190 |
|
n[7].addProperty(p, n[1]) |
191 |
|
|
192 |
|
c.set(n[2], -1, n[1]) |
193 |
|
assert c.getRotationIndex() == 0 and c.dir == -1 |
194 |
|
c.rotate(1) |
195 |
|
assert c.getRotationIndex() == 1 and c.dir == 1 |
196 |
|
|
197 |
|
c.set(n[1], 1, n[2]) |
198 |
|
assert c.getRotationIndex() == 0 and c.dir == 1 |
199 |
|
c.rotate(1) |
200 |
|
assert c.getRotationIndex() == 1 and c.dir == -1 |