Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
A committed Jul 15, 2024
1 parent 410d224 commit 96a978f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: poetry install

- name: test
run: poetry run pytest --cache-clear --cov=zapusk > pytest-coverage.txt
run: poetry run pytest --cache-clear --cov=zapusk | tee pytest-coverage.txt

- name: Pytest coverage comment
if: matrix.python-version == '3.11'
Expand Down
4 changes: 2 additions & 2 deletions zapusk/client/command_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
class CommandManager:
def __init__(
self,
config_service=ConfigService(),
config_service=None,
output=Output(),
colors=None,
api_client: Optional[ApiClient] = None,
) -> None:
self.output = output
self.config_service = config_service
self.config_service = config_service if config_service else ConfigService()
config = self.config_service.get_config()

self.api_client = (
Expand Down
15 changes: 15 additions & 0 deletions zapusk/client/command_testcase.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
from unittest import TestCase
from unittest.mock import MagicMock
from zapusk.client.api_client import ApiClient
from testfixtures import TempDirectory

from zapusk.services.config.service import ConfigService

from .output import Output
from .command_manager import CommandManager


CONFIG_DATA = ""


class CommandTestCase(TestCase):
def setUp(self) -> None:
self.temp_dir = TempDirectory()
self.config_file = self.temp_dir / "config.yml"
self.config_file.write_text(CONFIG_DATA)
self.config_service = ConfigService(
config_path=f"{self.temp_dir.path}/config.yml"
)

self.printer = MagicMock()
self.output = Output(
printer=self.printer,
Expand All @@ -18,9 +31,11 @@ def setUp(self) -> None:
output=self.output,
api_client=self.api_client,
colors=False,
config_service=self.config_service,
)
return super().setUp()

def tearDown(self) -> None:
self.temp_dir.cleanup()
self.printer.reset_mock()
return super().tearDown()
3 changes: 1 addition & 2 deletions zapusk/services/scheduler_service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@


logger = logging.getLogger(__name__)
config_service = ConfigService()


class SchedulerService:
Expand All @@ -22,7 +21,7 @@ def __init__(
interval: float = 1,
) -> None:
self.__interval = interval
self.__config_service = config_service
self.__config_service = config_service if config_service else ConfigService()
self.__executor_manager_service = executor_manager_service
self.__scheduled_jobs = [j for j in config_service.list_jobs() if j.schedule]
logger.info(f"Scheduled jobs detected {[i.id for i in self.__scheduled_jobs]}")
Expand Down

0 comments on commit 96a978f

Please sign in to comment.