-
Notifications
You must be signed in to change notification settings - Fork 875
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add unit test for
io.vasp.help
(#4020)
* enable TLS cert verify * use https over http * explicitly declare bs4 * add bs4 as opt dep * reduce timeout in CI to 60 secs * add test for io.vasp.help * add test for get_incar_tags * declare html parser * reduce test timeout to 5 sec * use pytest importorskip * also except timeout and assert incar tags as list * bump python to 3.10+ in readme, thanks @QuantumChemist * update `test_get_incar_tags` to check incar_parameters.json * skip init for cls method test * add missing VASP wiki INCAR page * include length in error msg * fix typo * update doc py 3.9 to 3.10 * reduce requests timeout to 60 secs, 600 sec might be impractical * make comment docstring * revert to just assert incar_tags_wiki * assert some hard coded INCAR tags
- Loading branch information
1 parent
edcd465
commit ed52258
Showing
15 changed files
with
74 additions
and
29 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,44 @@ | ||
from __future__ import annotations | ||
|
||
import io | ||
from unittest.mock import patch | ||
|
||
import pytest | ||
import requests | ||
|
||
from pymatgen.io.vasp.help import VaspDoc | ||
|
||
BeautifulSoup = pytest.importorskip("bs4").BeautifulSoup | ||
|
||
|
||
try: | ||
website_down = requests.get("https://www.vasp.at", timeout=5).status_code != 200 | ||
except (requests.exceptions.ConnectionError, requests.exceptions.ReadTimeout): | ||
website_down = True | ||
|
||
|
||
@pytest.mark.skipif(website_down, reason="www.vasp.at is down") | ||
class TestVaspDoc: | ||
@pytest.mark.parametrize("tag", ["ISYM"]) | ||
def test_print_help(self, tag): | ||
vasp_doc = VaspDoc() | ||
with patch("sys.stdout", new=io.StringIO()) as fake_stdout: | ||
vasp_doc.print_help(tag) | ||
output = fake_stdout.getvalue() | ||
|
||
assert tag in output | ||
|
||
@pytest.mark.parametrize("tag", ["ISYM"]) | ||
def test_get_help(self, tag): | ||
docstr = VaspDoc.get_help(tag) | ||
|
||
assert tag in docstr | ||
|
||
def test_get_incar_tags(self): | ||
"""Get all INCAR tags and check incar_parameters.json file.""" | ||
incar_tags_wiki = VaspDoc.get_incar_tags() | ||
assert isinstance(incar_tags_wiki, list) | ||
|
||
known_incar_tags = ("ENCUT", "ISMEAR") | ||
for tag in known_incar_tags: | ||
assert tag in incar_tags_wiki |