-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Implement automatic execution of rollback scripts
See #37 and #6 (comment) for details Tests - - Added test cases for rollbacker.py Refactor - - Split the rollbacker.rollback() function Style - - Formatted main.py, os_utils.py, rollbacker.py, and rollbacker_test.py using isort and black - `isort --python-version 310 --profile google --line-length 80 --src-path "src/code"` - `black --line-length 80 --target-version py310 --target-version py311 --target-version py312`
- Loading branch information
Showing
4 changed files
with
176 additions
and
27 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
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,22 @@ | ||
import os | ||
import unittest | ||
|
||
from . import rollbacker | ||
|
||
# For testing, we can access private methods. | ||
# pyright: reportPrivateUsage=false | ||
|
||
|
||
class TestCreateAndChmodScript(unittest.TestCase): | ||
def test_create_and_chmod(self): | ||
contents = [ | ||
"This file is used for unit testing the yabsnap rollbacker module, generated from yabsnap." | ||
] | ||
rollbacker._create_and_chmod_script(contents) | ||
self.assertTrue(os.path.exists(rollbacker._ROLLBACK_SCRIPT_FILEPATH)) | ||
self.assertTrue( | ||
os.access(rollbacker._ROLLBACK_SCRIPT_FILEPATH, mode=os.X_OK) | ||
) | ||
|
||
def tearDown(self): | ||
os.remove(rollbacker._ROLLBACK_SCRIPT_FILEPATH) |