-
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.
- Loading branch information
имя фамилия
committed
Jun 21, 2023
1 parent
99407e4
commit f679517
Showing
25 changed files
with
88 additions
and
222 deletions.
There are no files selected for viewing
Binary file not shown.
This file was deleted.
Oops, something went wrong.
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
Binary file not shown.
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,19 @@ | ||
[flake8] | ||
accept-encodings = utf-8 | ||
max-complexity = 6 | ||
statistics = False | ||
max-line-length = 80 | ||
enable-extensions = G | ||
isort-show-traceback = True | ||
|
||
exclude = .venv,dist,build | ||
|
||
per-file-ignores = | ||
# init modules can contain the local imports, logic, unused imports | ||
__init__.py: F401 | ||
|
||
[isort] | ||
multi_line_output = 3 | ||
include_trailing_comma = true | ||
default_section = FIRSTPARTY | ||
line_length = 80 |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
tests/fixtures/recursive_data_yml/sample_output_recursion.yaml
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
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 |
---|---|---|
@@ -1,62 +1,22 @@ | ||
from gendiff import generate_diff | ||
import pytest | ||
LAST_ELEM = -1 | ||
|
||
|
||
def get_recursion_yaml(): | ||
path_file1 = 'tests/fixtures/recursive_data_yml/file1.yaml' | ||
path_file2 = 'tests/fixtures/recursive_data_yml/file2.yaml' | ||
path_sample_file = 'tests/fixtures/recursive_data_yml/' \ | ||
'sample_output_recursion.yaml' | ||
with open(path_sample_file, 'r', encoding='utf=8') as sample: | ||
return path_file1, path_file2, sample.read().rstrip() | ||
|
||
|
||
def get_recursion_json(): | ||
path_file1 = 'tests/fixtures/recursive_data_json/file1.json' | ||
path_file2 = 'tests/fixtures/recursive_data_json/file2.json' | ||
path_sample_file = 'tests/fixtures/recursive_data_json/' \ | ||
'sample_output_recursion.json' | ||
with open(path_sample_file, 'r', encoding='utf=8') as sample: | ||
return path_file1, path_file2, sample.read().rstrip() | ||
|
||
|
||
def get_files_json(): | ||
path_file1 = 'tests/fixtures/flat_data_json/file1.json' | ||
path_file2 = 'tests/fixtures/flat_data_json/file2.json' | ||
path_sample_file = 'tests/fixtures/flat_data_json/sample_output.json' | ||
with open(path_sample_file, 'r', encoding='utf=8') as sample: | ||
return path_file1, path_file2, sample.read().rstrip() | ||
|
||
|
||
def get_files_yaml(): | ||
path_file1 = 'tests/fixtures/flat_data_yml/file1.yml' | ||
path_file2 = 'tests/fixtures/flat_data_yml/file2.yml' | ||
path_sample_file = 'tests/fixtures/flat_data_yml/sample_output.yml' | ||
with open(path_sample_file, 'r', encoding='utf=8') as sample: | ||
return path_file1, path_file2, sample.read().rstrip() | ||
|
||
|
||
def test_json(): | ||
result_data = generate_diff(*get_recursion_json()[:LAST_ELEM], 'json') | ||
sample_file = open('tests/fixtures/check_json.json', 'r').read().rstrip() | ||
verification_file = sample_file | ||
assert result_data == verification_file | ||
|
||
|
||
def test_stylish(): | ||
files_for_test = (get_files_yaml(), | ||
get_files_json(), | ||
get_recursion_json(), | ||
get_recursion_yaml()) | ||
|
||
for files in files_for_test: | ||
result_data = generate_diff(*files[:LAST_ELEM], 'stylish') | ||
verification_file = files[LAST_ELEM] | ||
assert result_data == verification_file | ||
|
||
|
||
def test_plain(): | ||
result_data = generate_diff(*get_recursion_json()[:LAST_ELEM], 'plain') | ||
sample_file = open('tests/fixtures/sample_file.json', 'r').read().rstrip() | ||
verification_file = sample_file | ||
assert result_data == verification_file | ||
@pytest.mark.parametrize('path1, path2, formatter, expected', [ | ||
('tests/fixtures/flat_file1.json', | ||
'tests/fixtures/flat_file2.json', 'stylish', | ||
'tests/fixtures/result_flat_file.txt'), | ||
('tests/fixtures/recursion_file1.json', | ||
'tests/fixtures/recursion_file2.yaml', 'stylish', | ||
'tests/fixtures/recursion_result.txt'), | ||
('tests/fixtures/recursion_file1.json', | ||
'tests/fixtures/recursion_file2.yaml', 'plain', | ||
'tests/fixtures/plain_result.txt'), | ||
('tests/fixtures/recursion_file1.json', | ||
'tests/fixtures/recursion_file2.yaml', 'json', | ||
'tests/fixtures/result_json_format.txt')]) | ||
def test_generat_diff(path1, path2, formatter, expected): | ||
with open(expected, 'r') as file: | ||
res = file.read().strip() | ||
assert generate_diff(path1, path2, formatter) == res |