Skip to content

Commit

Permalink
force _download_and_unzip_atomic_densities to be called in pytest
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuan Chiang committed Jan 2, 2024
1 parent aba55c7 commit 2c95aff
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions tests/command_line/test_chargemol_caller.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_parse_chargemol(monkeypatch, mock_xyz):


def fake_download(self, version: str = "latest", verbose: bool = True) -> None:
print("fake download")
extraction_path = "~/.cache/pymatgen/ddec"
os.makedirs(os.path.expanduser(extraction_path), exist_ok=True)

Expand Down Expand Up @@ -129,18 +130,17 @@ def test_fake_download_and_modify_path(monkeypatch):
monkeypatch.setattr(
ChargemolAnalysis,
"_download_and_unzip_atomic_densities",
lambda self, version, verbose: fake_download(self),
lambda self: fake_download(self),
)

# Create an instance of ChargemolAnalysis
test_dir = f"{TEST_FILES_DIR}/chargemol/spin_unpolarized"

ca = ChargemolAnalysis(
path=test_dir,
# atomic_densities_path=os.path.expanduser("~/.cache/pymatgen/ddec"),
atomic_densities_path="fake_path", # force _download_and_unzip_atomic_densities to be called
run_chargemol=False,
)

# Your assertions
assert ca._atomic_densities_path == os.getcwd()
# assert ca._atomic_densities_path == os.path.expanduser("~/.cache/pymatgen/ddec")
# TODO: Add more tests to ensure Chargemol was run correctly
assert ca._atomic_densities_path == os.path.expanduser("~/.cache/pymatgen/ddec")

0 comments on commit 2c95aff

Please sign in to comment.