From a11acee3595d276391d630443526eab3e23a365b Mon Sep 17 00:00:00 2001 From: Almaz Ilaletdinov Date: Mon, 27 May 2024 14:58:51 +0300 Subject: [PATCH 1/2] Implement integration test --- ondivi/__main__.py | 25 ++++++++- pyproject.toml | 1 + tests/fixtures/ondivi-test-repo.zip | Bin 0 -> 21208 bytes tests/it/test_app.py | 81 ++++++++++++++++++++++++++++ tests/{ => unit}/test_main.py | 0 5 files changed, 106 insertions(+), 1 deletion(-) create mode 100644 tests/fixtures/ondivi-test-repo.zip create mode 100644 tests/it/test_app.py rename tests/{ => unit}/test_main.py (100%) diff --git a/ondivi/__main__.py b/ondivi/__main__.py index 76e0940..a7c1491 100644 --- a/ondivi/__main__.py +++ b/ondivi/__main__.py @@ -26,6 +26,7 @@ only for changed lines in a Git repo. """ +import argparse import sys from contextlib import suppress @@ -99,10 +100,32 @@ def controller(diff: Diff, violations: list[str]) -> list[str]: def main() -> None: """Entrypoint.""" + parser = argparse.ArgumentParser( + description='\n'.join([ + 'Ondivi (Only diff violations).\n', + 'Python script filtering coding violations, identified by static analysis,', + 'only for changed lines in a Git repo.\n', + 'Usage example:\n', + 'flake8 script.py | ondivi', + ]), + formatter_class=argparse.RawTextHelpFormatter, + ) + parser.add_argument( + '--baseline', + dest='baseline', + type=str, + default='master', + help=' '.join([ + 'Commit or branch which will contain legacy code.', + 'Program filter out violations on baseline', + '(default: "master")', + ]), + ) + args = parser.parse_args() violations = sys.stdin.read().strip().splitlines() sys.stdout.write('\n'.join( controller( - Repo('.').git.diff('--unified=0', 'origin/master..HEAD'), + Repo('.').git.diff('--unified=0', args.baseline), violations, ), )) diff --git a/pyproject.toml b/pyproject.toml index c3144bc..c902a22 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,6 +61,7 @@ ignore = [ "ARG002", # Unused method argument "D203", # no-blank-line-before-class "D213", # multi-line-summary-first-line + "D401", # First line of docstring should be in imperative mood "D418", # Function decorated with `@overload` shouldn't contain a docstring "FBT001", # Boolean-typed positional argument in function definition "FBT002", # Boolean-typed positional argument in function definition diff --git a/tests/fixtures/ondivi-test-repo.zip b/tests/fixtures/ondivi-test-repo.zip new file mode 100644 index 0000000000000000000000000000000000000000..8920e586c66b0e7b4320d9ff07542af0d85c5de5 GIT binary patch literal 21208 zcmd6PbySsG*Du{5os!bs9a4fIAYIbkT@p%nNJ$9NDbn37-Jx_ycM1}BZ_mdodf^<; zd%r*Ka%{GYXN(!YIoDik&1e01E(s2S4gwq@Hnl20{_{USP(X-4tSt3S98Ku#4eadc zYz?ff7!(x{L7?MI6$}#rAK3WhCWI5N{y8*%7J)!rS;aKB09XksI&K7L?xooAZB?Gz%0p( zW``bmXlKVFi5{JcFv|93OIrR^ysxWkLN*7AD_;pk6m>?&CHE_$7BRC|RDl3|?%EXnPY&Xo< z=FuA0JYuyV&c^x-9n&V91|5jKfy*QHjiW;>{8;G9EUc*FTg%3aEA}}cKn73;UU~p? zfhPY1$oG~rfCnH1_c~*xYigipZ}%5a!T$pk@cTD+e&*M0ps)b4aqpEaE-EPUPcYF) zNR`S_N=VU+4~R=WqZ%KOqNRUIw+Qwl`ZOkX**E|dKs7&|yKMmA0SMl`2AEhH{?E(- z1_+n}cLeIE;NMZZU$D8A(SHlsQ-H<9_gbuPV5etmVr_3?W%(cEfHvP@H+)|YU`|TO zQcBQ$V(6#sV#q5~5|`?tm8I%4t*s5F+ff$r;ia(Z4mi=5`Dih;N8sQBiEAZL zP<|a`kJk$yvynV@vupe=Af`<7rgebhT@Q^or}ZJMRU9F>tD2#7o~9t#b3yTle42GdlgfIB}YH?Y9pcJ=|_De1l0BrGE(^;AJiROG3Gl)Tt~ybihB>%-n2+OB84vf}*% zeSNeGf2GLc7p@T$fD)jhpDA+N1i*v8N$8vU!p8oy#N4C*|3y4I<4^Ixd45Mwe~SM- z4IkYL;EnaxI(lY*DY%)8_ogEdj(@M<*GhGxV8%l?z0MjSCaew}skaOo(Mlg4^fX(lST1-4|vhmn->S*^b# z{L{Ow*H|$ppLmHPU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*y)FHzUJS<}UGn$k~4``O}HJi1IgDwgs6%?{MM|Y4bll z0j@%~S?EBz@Xg5Z^t)HbpV8=VdviMrff|6U_M5RSC=clP{9hsY;mytZ^q+}xFGKBD zuWr-Nfh_l%k>Oc*ude^l{eWxhJ%1YDwokvW;Xvl{&Da)X1Y9({+oxX%qdI1c(a3*>?C;f~0`8^U?cj~NKcbcYRQG#^ z0Ey){V_VSXAJzRK&HPUl4*#RVU#kc(E&nDpfu7vnCIWx|HGV8G{{-kC(a`_$5161p zKyS0KfkgD1k>MG6ueyIjOTS6an+b875e?*a-wZ(2hrQ3eKW2L0C<6-pJvo8Lx0|so z7zH><-kqF3w^;vnLAy|5w%Z82_yLUy*fwSAF|hI`D1z&Di#A1N>c^yTkjJ*FWEz{|kb^@9KANUA_a} zeZLvoo@#i1ul~Qj3IDqZx37)?Z>`*nZO=oJzc=CE-}(Dp_wBnhzq(&V`j5K*yQ^xy zn{fLg%dhS~qWlLF{`D1}-*w-ItN#}lCVp3Z`<)B$E%VLT_B3Mnd&U3io%8Q% zZ}%X7jkg`3*YmgW{_kGz+!z4#@At***Nwp!K*Q;718#LQ{&Y11s{4JX_3PTn#r?PH z{;(1Ha~lG5?sgLp*b2QFq@Hi@)poOu{9kK~-XMOnSGnEG`_-sQp8FuUG3tM<8+qF( z;QsJ-6YW={e0l%LsQ%>SA)w|i;8e%{T< z@Py>QPv@=q@LTKbp6=d_qc +# +# 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)' diff --git a/tests/test_main.py b/tests/unit/test_main.py similarity index 100% rename from tests/test_main.py rename to tests/unit/test_main.py From cdc277e7540bc0659060794b65da2af74d2e3962 Mon Sep 17 00:00:00 2001 From: Almaz Ilaletdinov Date: Mon, 27 May 2024 15:00:50 +0300 Subject: [PATCH 2/2] Change Makefile --- Makefile | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index ceaa71f..0d624ac 100644 --- a/Makefile +++ b/Makefile @@ -26,5 +26,10 @@ lint: poetry run flake8 ondivi tests poetry run mypy ondivi tests --strict -test: - poetry run pytest --cov=ondivi --cov-report=term-missing:skip-covered -vv +test: unit it + +unit: + poetry run pytest tests/unit --cov=ondivi --cov-report=term-missing:skip-covered -vv + +it: # integration tests + poetry run pytest tests/it -s -vv