-
Notifications
You must be signed in to change notification settings - Fork 247
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix add_dot_path_to_config and add tests for configs
- Loading branch information
Showing
4 changed files
with
43 additions
and
15 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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import os | ||
import sys | ||
from .testing_utility_functions import setup_dirs_and_env_vars_and_create_config, clean_up_dirs_and_env_vars, FAKE_HOME_DIR | ||
sys.path.insert(0, "../shallow_backup") | ||
from shallow_backup.config import get_config, add_dot_path_to_config | ||
from shallow_backup.utils import strip_home | ||
|
||
|
||
class TestConfigMethods: | ||
"""Test the config methods.""" | ||
|
||
@staticmethod | ||
def setup_method(): | ||
setup_dirs_and_env_vars_and_create_config() | ||
|
||
@staticmethod | ||
def teardown_method(): | ||
clean_up_dirs_and_env_vars() | ||
|
||
def test_add_path(self): | ||
config = get_config() | ||
home_path = os.path.expanduser("~") | ||
invalid_path = "some_random_nonexistent_path" | ||
path_to_add = os.path.join(home_path, invalid_path) | ||
new_config = add_dot_path_to_config(config, path_to_add) | ||
assert strip_home(invalid_path) not in new_config["dotfiles"] | ||
|
||
valid_path = "valid" | ||
path_to_add = os.path.join(FAKE_HOME_DIR, valid_path) | ||
os.mkdir(path_to_add) | ||
new_config = add_dot_path_to_config(config, path_to_add) | ||
from pprint import pprint | ||
pprint(new_config) | ||
stripped_home_path = strip_home(path_to_add) | ||
assert stripped_home_path in new_config["dotfiles"] | ||
assert isinstance(new_config["dotfiles"][stripped_home_path], dict) |
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