-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #227 from rafsaf/improve-tests
Improve tests
- Loading branch information
Showing
14 changed files
with
353 additions
and
82 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
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
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,31 @@ | ||
# Copyright: (c) 2024, Rafał Safin <rafal.safin@rafsaf.pl> | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
|
||
from freezegun import freeze_time | ||
|
||
from backuper import config | ||
from backuper.backup_targets.file import File | ||
|
||
from .conftest import CONST_TOKEN_URLSAFE, FILE_1 | ||
|
||
|
||
@freeze_time("2024-03-14") | ||
def test_run_file_backup_output_file_has_proper_name() -> None: | ||
file = File(target_model=FILE_1) | ||
out_backup = file.make_backup() | ||
|
||
escaped_file_name = FILE_1.abs_path.name.replace(".", "") | ||
out_file = ( | ||
f"{file.env_name}/" | ||
f"{file.env_name}_20240314_0000_{escaped_file_name}_{CONST_TOKEN_URLSAFE}" | ||
) | ||
out_path = config.CONST_BACKUP_FOLDER_PATH / out_file | ||
assert out_backup == out_path | ||
|
||
|
||
def test_run_file_backup_output_file_has_exact_same_content() -> None: | ||
file = File(target_model=FILE_1) | ||
out_backup = file.make_backup() | ||
|
||
assert out_backup.read_text() == FILE_1.abs_path.read_text() |
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,34 @@ | ||
# Copyright: (c) 2024, Rafał Safin <rafal.safin@rafsaf.pl> | ||
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt) | ||
|
||
|
||
from freezegun import freeze_time | ||
|
||
from backuper import config | ||
from backuper.backup_targets.folder import Folder | ||
|
||
from .conftest import CONST_TOKEN_URLSAFE, FOLDER_1 | ||
|
||
|
||
@freeze_time("2024-03-14") | ||
def test_run_folder_backup_output_folder_has_proper_name() -> None: | ||
folder = Folder(target_model=FOLDER_1) | ||
out_backup = folder.make_backup() | ||
|
||
folder_name = FOLDER_1.abs_path.name | ||
out_file = ( | ||
f"{folder.env_name}/" | ||
f"{folder.env_name}_20240314_0000_{folder_name}_{CONST_TOKEN_URLSAFE}" | ||
) | ||
out_path = config.CONST_BACKUP_FOLDER_PATH / out_file | ||
assert out_backup == out_path | ||
|
||
|
||
def test_run_folder_backup_output_file_in_folder_has_exact_same_content() -> None: | ||
folder = Folder(target_model=FOLDER_1) | ||
out_backup = folder.make_backup() | ||
|
||
file_in_folder = FOLDER_1.abs_path / "file.txt" | ||
file_in_out_folder = out_backup / "file.txt" | ||
|
||
assert file_in_folder.read_text() == file_in_out_folder.read_text() |
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
Oops, something went wrong.