TESTS TESTS ADDED MORE TEST TESTED GRESOURCES TESTS TESTS I LOVE TESTS SO MUCH

- Fully covered gresource orchestrator and it helpers with tests
- Use abstract command runner INSTEAD OF SUBPROCESS in gresources
- Replaced some subprocesses by builtin functions
This commit is contained in:
Vladyslav Hroshev
2025-04-06 21:56:27 +03:00
parent 9bb229df7d
commit 31e1a3deb9
20 changed files with 661 additions and 313 deletions

View File

@@ -1,6 +1,5 @@
import os
import shutil
import subprocess
from scripts.utils.gresource import GresourceBackupNotFoundError
from scripts.utils.logger.logger import LoggerFactory
@@ -23,7 +22,7 @@ class GresourceBackuperManager:
class GresourceBackuper:
def __init__(self, destination_file: str, backup_file, logger_factory: LoggerFactory):
def __init__(self, destination_file: str, backup_file: str, logger_factory: LoggerFactory):
self.destination_file = destination_file
self.backup_file = backup_file
self.logger_factory = logger_factory
@@ -41,7 +40,6 @@ class GresourceBackuper:
os.remove(self.backup_file)
shutil.copy2(self.destination_file, self.backup_file)
# subprocess.run(["cp", "-aT", self.destination_file, self.backup_file], check=True)
backup_line.success("Backed up gresource files.")
@@ -49,4 +47,6 @@ class GresourceBackuper:
if not os.path.exists(self.backup_file):
raise GresourceBackupNotFoundError(self.backup_file)
subprocess.run(["mv", "-f", self.backup_file, self.destination_file], check=True)
shutil.move(self.backup_file, self.destination_file)
self.logger_factory.create_logger().success("Restored gresource files.")