Skip to content

Commit

Permalink
Add tests for filesystem constants
Browse files Browse the repository at this point in the history
  • Loading branch information
cmutel committed Oct 10, 2023
1 parent d6fa5e3 commit 68e3e05
Showing 1 changed file with 57 additions and 0 deletions.
57 changes: 57 additions & 0 deletions tests/test_filesystem_constants.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from premise.filesystem_constants import (
DATA_DIR, INVENTORY_DIR, VARIABLES_DIR, IAM_OUTPUT_DIR,
DIR_CACHED_DB
)
import os
from pathlib import Path

dd_root = str(DATA_DIR.parent.parent)
cd_root = str(DIR_CACHED_DB.parent.parent)


def test_data_dir():
assert isinstance(DATA_DIR, Path)
assert DATA_DIR.is_dir()
assert len(list(DATA_DIR.iterdir())) > 2
for fp in DATA_DIR.iterdir():
assert os.access(fp, os.R_OK)
assert dd_root not in cd_root and cd_root not in dd_root


def test_inventory_dir():
assert isinstance(INVENTORY_DIR, Path)
assert INVENTORY_DIR.is_dir()
for fp in INVENTORY_DIR.iterdir():
assert os.access(fp, os.R_OK)
assert len(list(INVENTORY_DIR.iterdir())) > 2
assert str(DATA_DIR) in str(INVENTORY_DIR)


def test_variables_dir():
assert isinstance(VARIABLES_DIR, Path)
assert VARIABLES_DIR.is_dir()
assert len(list(VARIABLES_DIR.iterdir())) > 2
for fp in VARIABLES_DIR.iterdir():
assert os.access(fp, os.R_OK)
assert str(DATA_DIR) not in str(VARIABLES_DIR)
assert dd_root in str(VARIABLES_DIR)
assert cd_root not in str(VARIABLES_DIR)


def test_iam_output_dir():
assert isinstance(IAM_OUTPUT_DIR, Path)
assert IAM_OUTPUT_DIR.is_dir()
for fp in IAM_OUTPUT_DIR.iterdir():
assert os.access(fp, os.R_OK)
assert len(list(IAM_OUTPUT_DIR.iterdir())) > 2
assert str(DATA_DIR) in str(IAM_OUTPUT_DIR)


def test_user_data_dir():
assert isinstance(DIR_CACHED_DB, Path)
assert DIR_CACHED_DB.is_dir()
assert os.access(DIR_CACHED_DB, os.W_OK)
assert os.access(DIR_CACHED_DB, os.R_OK)
assert cd_root in str(DIR_CACHED_DB)
assert dd_root not in str(DIR_CACHED_DB)
assert "cache" in str(DIR_CACHED_DB)

0 comments on commit 68e3e05

Please sign in to comment.