-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
45 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import pytest | ||
import shutil | ||
from impactlab_tools.utils import paralog | ||
|
||
def test_claiming(): | ||
statman1 = StatusManager('test', 'Testing process', 'testing-paralog', 60*60) | ||
print statman1.logpath | ||
assert statman1.claim("testing-paralog"), "Cannot claim directory!" | ||
|
||
statman2 = StatusManager('test', 'Testing process', 'testing-paralog', 60*60) | ||
print statman2.logpath | ||
assert not statman2.claim("testing-paralog"), "Accidentally claimed directory!" | ||
|
||
statman1.update("testing-paralog", "New status.") | ||
statman1.release("testing-paralog", "First pass complete.") | ||
|
||
assert statman2.claim("testing-paralog"), "Cannot claim directory afterwards!" | ||
|
||
statman2.release("testing-paralog", "Second pass complete.") | ||
|
||
logpath1 = statman1.logpath | ||
logpath2 = statman2.logpath | ||
|
||
del statman2 # need to delete in opposite order for our test | ||
del statman1 | ||
|
||
print logpath1 | ||
print logpath2 | ||
|
||
with open(StatusManager.globalstatus_filepath("testing-paralog"), 'r') as fp: | ||
print fp.read() | ||
|
||
shutil.rmtree('testing-paralog') |