|
24 | 24 | import pytest |
25 | 25 |
|
26 | 26 | from lxml import etree |
| 27 | +from hashlib import sha256 |
27 | 28 |
|
28 | 29 | from nw.core.project import NWProject, NWItem, NWTree |
29 | 30 | from nw.enum import nwItemClass, nwItemType, nwItemLayout |
@@ -394,22 +395,33 @@ def testCoreTree_MakeHandles(monkeypatch, dummyGUI): |
394 | 395 | tHandle = theTree._makeHandle() |
395 | 396 | assert tHandle == "73475cb40a568" |
396 | 397 |
|
397 | | - # Add the next in line to the project to foprce duplicate |
| 398 | + # Add the next in line to the project to force duplicate |
398 | 399 | theTree._projTree["44cb730c42048"] = None |
399 | 400 | tHandle = theTree._makeHandle() |
400 | 401 | assert tHandle == "71ee45a3c0db9" |
401 | 402 |
|
402 | 403 | # Fix the time() function and force a handle collission |
403 | 404 | theTree.setSeed(None) |
| 405 | + theTree._handleCount = 0 |
404 | 406 | monkeypatch.setattr("nw.core.tree.time", lambda: 123.4) |
405 | 407 |
|
406 | 408 | tHandle = theTree._makeHandle() |
407 | 409 | theTree._projTree[tHandle] = None |
408 | | - assert tHandle == "5f466d7afa48b" |
| 410 | + newSeed = "123.4_0_" |
| 411 | + assert tHandle == sha256(newSeed.encode()).hexdigest()[0:13] |
409 | 412 |
|
410 | 413 | tHandle = theTree._makeHandle() |
411 | 414 | theTree._projTree[tHandle] = None |
412 | | - assert tHandle == "a79acf4c634a7" |
| 415 | + newSeed = "123.4_1_" |
| 416 | + assert tHandle == sha256(newSeed.encode()).hexdigest()[0:13] |
| 417 | + |
| 418 | + # Reset the count and the handle for 0 and 1 should be duplicates |
| 419 | + # which forces the function to add the '!' |
| 420 | + theTree._handleCount = 0 |
| 421 | + tHandle = theTree._makeHandle() |
| 422 | + theTree._projTree[tHandle] = None |
| 423 | + newSeed = "123.4_1_!" |
| 424 | + assert tHandle == sha256(newSeed.encode()).hexdigest()[0:13] |
413 | 425 |
|
414 | 426 | # END Test testCoreTree_MakeHandles |
415 | 427 |
|
|
0 commit comments