@@ -171,3 +171,105 @@ def mock_isatty():
171
171
172
172
# res = pathins.stringbuilder.overlap_result("TEST", test_pass=True, nocolor=True)
173
173
# assert res == "[ TEST ]: Yes"
174
+
175
+
176
+ def test_direction_result_no_contours_default (monkeypatch ):
177
+ # mock tty
178
+ def mock_isatty ():
179
+ return True
180
+
181
+ # apply the monkeypatch for sys.stdout.isatty()
182
+ monkeypatch .setattr (pathins .stringbuilder , "IS_A_TTY" , mock_isatty )
183
+
184
+ res = pathins .stringbuilder .direction_result ("TEST" , True , 0 , [], nocolor = False )
185
+ assert res == "[ \033 [1;96mTEST\033 [0m ]: no contours"
186
+
187
+
188
+ def test_direction_result_no_contours_nocolor (monkeypatch ):
189
+ # mock tty
190
+ def mock_isatty ():
191
+ return True
192
+
193
+ # apply the monkeypatch for sys.stdout.isatty()
194
+ monkeypatch .setattr (pathins .stringbuilder , "IS_A_TTY" , mock_isatty )
195
+
196
+ res = pathins .stringbuilder .direction_result ("TEST" , True , 0 , [], nocolor = True )
197
+ assert res == "[ TEST ]: no contours"
198
+
199
+
200
+ def test_direction_result_clockwise_with_component_transform (monkeypatch ):
201
+ # mock tty
202
+ def mock_isatty ():
203
+ return True
204
+
205
+ # apply the monkeypatch for sys.stdout.isatty()
206
+ monkeypatch .setattr (pathins .stringbuilder , "IS_A_TTY" , mock_isatty )
207
+
208
+ res = pathins .stringbuilder .direction_result (
209
+ "TEST" , True , 2 , [("A" , [[1.0 , 0 ], [0 , 1.0 ]])], nocolor = False
210
+ )
211
+ assert res == (
212
+ f"[ \033 [1;96mTEST\033 [0m ]: clockwise{ os .linesep } "
213
+ f" with component 'A' transform: [[1.0, 0], [0, 1.0]]"
214
+ )
215
+
216
+
217
+ def test_direction_result_clockwise_with_two_components (monkeypatch ):
218
+ # mock tty
219
+ def mock_isatty ():
220
+ return True
221
+
222
+ # apply the monkeypatch for sys.stdout.isatty()
223
+ monkeypatch .setattr (pathins .stringbuilder , "IS_A_TTY" , mock_isatty )
224
+
225
+ res = pathins .stringbuilder .direction_result (
226
+ "TEST" ,
227
+ True ,
228
+ 2 ,
229
+ [("A" , [[1.0 , 0 ], [0 , 1.0 ]]), ("B" , [[1.0 , 0 ], [0 , 1.0 ]])],
230
+ nocolor = False ,
231
+ )
232
+ assert res == (
233
+ f"[ \033 [1;96mTEST\033 [0m ]: clockwise{ os .linesep } "
234
+ f" with component 'A' transform: [[1.0, 0], [0, 1.0]]{ os .linesep } "
235
+ f" with component 'B' transform: [[1.0, 0], [0, 1.0]]"
236
+ )
237
+
238
+
239
+ def test_direction_result_counterclockwise_with_component_transform (monkeypatch ):
240
+ # mock tty
241
+ def mock_isatty ():
242
+ return True
243
+
244
+ # apply the monkeypatch for sys.stdout.isatty()
245
+ monkeypatch .setattr (pathins .stringbuilder , "IS_A_TTY" , mock_isatty )
246
+
247
+ res = pathins .stringbuilder .direction_result (
248
+ "TEST" , False , 2 , [("A" , [[1.0 , 0 ], [0 , 1.0 ]])], nocolor = False
249
+ )
250
+ assert res == (
251
+ f"[ \033 [1;96mTEST\033 [0m ]: counter-clockwise{ os .linesep } "
252
+ f" with component 'A' transform: [[1.0, 0], [0, 1.0]]"
253
+ )
254
+
255
+
256
+ def test_direction_result_counterclockwise_with_two_components (monkeypatch ):
257
+ # mock tty
258
+ def mock_isatty ():
259
+ return True
260
+
261
+ # apply the monkeypatch for sys.stdout.isatty()
262
+ monkeypatch .setattr (pathins .stringbuilder , "IS_A_TTY" , mock_isatty )
263
+
264
+ res = pathins .stringbuilder .direction_result (
265
+ "TEST" ,
266
+ False ,
267
+ 2 ,
268
+ [("A" , [[1.0 , 0 ], [0 , 1.0 ]]), ("B" , [[1.0 , 0 ], [0 , 1.0 ]])],
269
+ nocolor = False ,
270
+ )
271
+ assert res == (
272
+ f"[ \033 [1;96mTEST\033 [0m ]: counter-clockwise{ os .linesep } "
273
+ f" with component 'A' transform: [[1.0, 0], [0, 1.0]]{ os .linesep } "
274
+ f" with component 'B' transform: [[1.0, 0], [0, 1.0]]"
275
+ )
0 commit comments