You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
calculate-utils-4-lib/tests/templates/test_template_action.py

53 lines
2.0 KiB

import pytest
import os
from calculate.templates.template_processor import TemplateAction,\
TemplateParameters, DIR
template_action = TemplateAction()
TEST_DIRECTORY_PATH = os.path.join(os.getcwd(), 'tests/templates/testfiles')
@pytest.mark.template_action
class TestTemplateAction:
def test_chown_directory(self):
pass
def test_chmod_directory(self):
pass
def test_create_directory(self):
path_to_create = os.path.join(TEST_DIRECTORY_PATH,
'dir_tests/new_dir/new_subdir')
template_action.template_parameters = TemplateParameters(
{'chown':
'{0}:{1}'.format(os.getuid(),
os.getgid())},
DIR)
template_action._create_directory(target_path=path_to_create)
assert os.path.exists(path_to_create)
def test_link_directory(self):
path_to_source = os.path.join(TEST_DIRECTORY_PATH,
'dir_tests/new_dir/new_subdir')
path_to_link = os.path.join(TEST_DIRECTORY_PATH,
'dir_tests/new_dir/new_subdir_link')
template_action.source = path_to_source
template_action._link_directory(path_to_link)
template_action.source = False
assert os.path.exists(path_to_link) and os.path.islink(path_to_link)
def test_remove_directory(self):
directory_to_remove = os.path.join(TEST_DIRECTORY_PATH,
'dir_tests/dir')
link_to_remove = os.path.join(TEST_DIRECTORY_PATH,
'dir_tests/new_dir/new_subdir_link')
template_action._remove_directory(link_to_remove)
assert not os.path.exists(link_to_remove)
template_action._remove_directory(directory_to_remove)
assert not os.path.exists(directory_to_remove)