Skip to content

Commit

Permalink
remove utils
Browse files Browse the repository at this point in the history
  • Loading branch information
Ihor-Pryyma committed Jul 26, 2024
1 parent 799b7b3 commit ee85861
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 46 deletions.
7 changes: 5 additions & 2 deletions common/test/test_applicationinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from unittest.mock import patch
from threading import Thread

from test import generic, utils
from test import generic

sys.path.append(os.path.join(os.path.dirname(__file__), ".."))

Expand Down Expand Up @@ -70,7 +70,10 @@ def _createProcess(self):
return self.subproc.pid

def _killProcess(self):
utils.kill_subprocess(self.subproc)
if self.subproc:
subproc = self.subproc
subproc.kill()
subproc.wait()
self.subproc = None

def test_create_and_remove_pid_file(self):
Expand Down
31 changes: 26 additions & 5 deletions common/test/test_config_crontab.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,19 @@
See also test_schedule.py for low-level-Cron-behavior implemented in schedule
module."""
import unittest
import sys
import inspect
import os
import sys
import tempfile
import inspect
import unittest
from pathlib import Path
from unittest import mock

import pyfakefs.fake_filesystem_unittest as pyfakefs_ut

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))

import config
from test import utils


class Cron(unittest.TestCase):
Expand Down Expand Up @@ -81,7 +83,26 @@ def setUp(self):

def _create_config_file(self, parent_path):
"""Minimal config file"""
config_data = utils.config_template.format(
config_data = """
config.version={config_version}
profile1.snapshots.include.1.type={snapshot_type}
profile1.snapshots.include.1.value={snapshot_value}
profile1.snapshots.include.size={snapshot_size}
profile1.snapshots.no_on_battery={no_on_battery}
profile1.snapshots.notify.enabled={notify_enabled}
profile1.snapshots.path={snapshot_path}
profile1.snapshots.path.host={snapshot_host}
profile1.snapshots.path.profile={snapshot_profile}
profile1.snapshots.path.user={snapshot_user}
profile1.snapshots.preserve_acl={preserve_acl}
profile1.snapshots.preserve_xattr={preserve_xattr}
profile1.snapshots.remove_old_snapshots.enabled={remove_old_snapshots_enabled}
profile1.snapshots.remove_old_snapshots.unit={remove_old_snapshots_unit}
profile1.snapshots.remove_old_snapshots.value={remove_old_snapshots_value}
profile1.snapshots.rsync_options.enabled={rsync_options_enabled}
profile1.snapshots.rsync_options.value={rsync_options_value}
profiles.version={profiles_version}
""".format(
config_version=6,
snapshot_type=0,
snapshot_value='rootpath/source',
Expand Down
35 changes: 27 additions & 8 deletions common/test/test_plugin_usercallback.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
import sys
import inspect
import tempfile
import stat
import io
import stat
import sys
import tempfile
import unittest
import unittest.mock as mock
from pathlib import Path
from ast import literal_eval
from contextlib import redirect_stdout, redirect_stderr
from contextlib import redirect_stderr, redirect_stdout
from pathlib import Path

# This workaround will become obsolet when migrating to src-layout
sys.path.append(str(Path(__file__).parent))
sys.path.append(str(Path(__file__).parent / 'plugins'))

import pluginmanager
from config import Config
from test import utils
from snapshots import Snapshots, SID
from snapshots import SID, Snapshots
from usercallbackplugin import UserCallbackPlugin


Expand Down Expand Up @@ -209,7 +209,26 @@ def _create_source_and_destination_folders(cls, parent_path):
@classmethod
def _create_config_file(cls, parent_path):
"""Minimal config file"""
config_data = utils.config_template.format(
config_data = """
config.version={config_version}
profile1.snapshots.include.1.type={snapshot_type}
profile1.snapshots.include.1.value={snapshot_value}
profile1.snapshots.include.size={snapshot_size}
profile1.snapshots.no_on_battery={no_on_battery}
profile1.snapshots.notify.enabled={notify_enabled}
profile1.snapshots.path={snapshot_path}
profile1.snapshots.path.host={snapshot_host}
profile1.snapshots.path.profile={snapshot_profile}
profile1.snapshots.path.user={snapshot_user}
profile1.snapshots.preserve_acl={preserve_acl}
profile1.snapshots.preserve_xattr={preserve_xattr}
profile1.snapshots.remove_old_snapshots.enabled={remove_old_snapshots_enabled}
profile1.snapshots.remove_old_snapshots.unit={remove_old_snapshots_unit}
profile1.snapshots.remove_old_snapshots.value={remove_old_snapshots_value}
profile1.snapshots.rsync_options.enabled={rsync_options_enabled}
profile1.snapshots.rsync_options.value={rsync_options_value}
profiles.version={profiles_version}
""".format(
config_version=6,
snapshot_type=0,
snapshot_value=f'{parent_path}/{cls.NAME_SOURCE}',
Expand Down
6 changes: 4 additions & 2 deletions common/test/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
from unittest.mock import patch
from tempfile import NamedTemporaryFile, TemporaryDirectory
import pyfakefs.fake_filesystem_unittest as pyfakefs_ut
from test import generic, utils
from test import generic

sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
import tools
Expand Down Expand Up @@ -95,7 +95,9 @@ def _create_process(self, *args):
return self.subproc.pid

def _kill_process(self):
utils.kill_subprocess(self.subproc)
if self.subproc:
self.subproc.kill()
self.subproc.wait()
self.subproc = None

def test_sharePath(self):
Expand Down
29 changes: 0 additions & 29 deletions common/test/utils.py

This file was deleted.

0 comments on commit ee85861

Please sign in to comment.