-
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
1 parent
0bcf589
commit eddb975
Showing
8 changed files
with
186 additions
and
4 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
# The MIT License (MIT). | ||
# | ||
# Copyright (c) 2024 Almaz Ilaletdinov <[email protected]> | ||
# | ||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. | ||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE | ||
# OR OTHER DEALINGS IN THE SOFTWARE. | ||
|
||
"""Integration test with installing and check on real git repo.""" | ||
|
||
import os | ||
import subprocess | ||
import zipfile | ||
from pathlib import Path | ||
|
||
import pytest | ||
from _pytest.legacypath import TempdirFactory | ||
|
||
|
||
@pytest.fixture(scope='module') | ||
def current_dir() -> Path: | ||
"""Current directory for installing actual ondivi.""" | ||
return Path().absolute() | ||
|
||
|
||
# flake8: noqa: S603, S607. Not a production code | ||
@pytest.fixture(scope='module') | ||
def _test_repo(tmpdir_factory: TempdirFactory, current_dir: str) -> None: | ||
"""Real git repository.""" | ||
tmp_path = tmpdir_factory.mktemp('test') | ||
with zipfile.ZipFile('tests/fixtures/ondivi-test-repo.zip', 'r') as zip_ref: | ||
zip_ref.extractall(tmp_path) | ||
os.chdir(tmp_path / 'ondivi-test-repo') | ||
subprocess.run(['python', '-m', 'venv', 'venv'], check=True) | ||
subprocess.run(['venv/bin/pip', 'install', 'flake8', str(current_dir)], check=True) | ||
|
||
|
||
@pytest.mark.usefixtures('_test_repo') | ||
def test() -> None: | ||
"""Test script with real git repo.""" | ||
got = subprocess.run( | ||
['ondivi', '--baseline', '56faa56'], | ||
stdin=subprocess.Popen( | ||
['venv/bin/flake8', 'file.py'], | ||
stdout=subprocess.PIPE, | ||
).stdout, | ||
stdout=subprocess.PIPE, | ||
check=False, | ||
).stdout.decode('utf-8').strip() | ||
|
||
assert got == 'file.py:4:80: E501 line too long (119 > 79 characters)' | ||
|
||
|
||
@pytest.mark.usefixtures('_test_repo') | ||
def test_baseline_default() -> None: | ||
"""Test baseline default.""" | ||
got = subprocess.run( | ||
['ondivi'], | ||
stdin=subprocess.Popen( | ||
['venv/bin/flake8', 'file.py'], | ||
stdout=subprocess.PIPE, | ||
).stdout, | ||
stdout=subprocess.PIPE, | ||
check=False, | ||
).stdout.decode('utf-8').strip() | ||
|
||
assert got == 'file.py:4:80: E501 line too long (119 > 79 characters)' |
File renamed without changes.