-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed mandatory args and added tests
- Loading branch information
1 parent
3097d09
commit 17e9717
Showing
3 changed files
with
63 additions
and
9 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
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 |
---|---|---|
@@ -1,9 +1,52 @@ | ||
import pytest | ||
from dfttools.utils import run_utils | ||
import os | ||
from dfttoolkit.utils.run_utils import no_repeat | ||
|
||
|
||
class TestRunUtils: | ||
class TestNoRepeat: | ||
|
||
def test_no_repeat(self): | ||
# TODO | ||
pass | ||
calc_dir = ( | ||
f"{os.path.dirname(os.path.realpath(__file__))}/fixtures/default_aims_calcs/1" | ||
) | ||
|
||
def test_specified_dir_not_found(self): | ||
@no_repeat(calc_dir="bogus") | ||
def to_be_decorated(): | ||
return True | ||
|
||
with pytest.raises(ValueError) as excinfo: | ||
to_be_decorated() | ||
|
||
assert "bogus is not a directory." == str(excinfo.value) | ||
|
||
@pytest.mark.parametrize( | ||
("calc_dir", "force", "expected"), | ||
[ | ||
("./", False, True), | ||
( | ||
f"{os.path.dirname(os.path.realpath(__file__))}/fixtures/default_aims_calcs/1", | ||
True, | ||
True, | ||
), | ||
], | ||
) | ||
def test_default_dir_no_args(self, calc_dir, force, expected): | ||
@no_repeat(calc_dir=calc_dir, force=force) | ||
def to_be_decorated(): | ||
return True | ||
|
||
assert to_be_decorated() == expected | ||
|
||
def test_no_repeat(self, capfd): | ||
@no_repeat(calc_dir=self.calc_dir) | ||
def to_be_decorated(): | ||
return True | ||
|
||
to_be_decorated() | ||
|
||
out, err = capfd.readouterr() | ||
assert ( | ||
out | ||
== f"aims.out already exists in {self.calc_dir}. Skipping calculation.\n" | ||
) | ||
assert err == "" |