-
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.
* add test for parse_inputs * install python package (dev) * typo * 🎨 Format Python code with psf/black (#10) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * test sample size * typo * fix test sample size * 🎨 Format Python code with psf/black (#12) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * add test on sample size * fix assert for test_sample_greater_size_than_list * fix test_sample_greater_size_than_list * 🎨 Format Python code with psf/black (#13) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * test skeleton for test_git * 🎨 Format Python code with psf/black (#14) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * finish test common and start test for git * import datetime missing * typeerror: Integer required * return absolute month difference * typo * 🎨 Format Python code with psf/black (#17) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * test if code runs wihtin a py.test session * typo * print traces * test_branch_is_old: GREEN * test_branch_are_coupled: GREEN * change are_coupled -> contains * test_git pass * 🎨 Format Python code with psf/black (#18) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * test for is_empty_body * typo * test is_test_commit: GREEN * test for not_a_squased commit: GREEN * test if commit contains bad words: GREEN * test count coupled : GREEN! * test count_old_branches : GREEN * test process logs: GREEN * tes overall OK * some helpfull logs * 🎨 Format Python code with psf/black (#19) Co-authored-by: gcattan <gcattan@users.noreply.github.com> * Update run-pytest.yml * missing "-r" option in "is_old" * Update run-pytest.yml Co-authored-by: gcattan <gregoire.cattan@ibm.com> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: gcattan <gcattan@users.noreply.github.com>
- Loading branch information
1 parent
f9da082
commit 21a47ef
Showing
21 changed files
with
223 additions
and
59 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
from .is_empty_body import is_empty_body | ||
from .not_a_squashed_commit import not_a_squashed_commit | ||
from .count_bad_words import count_bad_words | ||
from .does_contain_bad_words import does_contain_bad_words | ||
from .is_test_commit import is_test_commit |
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
git_quality_check/indicators/commits/does_contain_bad_words.py
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,9 @@ | ||
def does_contain_bad_words(bad_words: list[str]): | ||
def _does_contain_bad_words(log: str): | ||
counter = 0 | ||
for word in bad_words: | ||
if word.lower() in log.lower().split(): | ||
counter += 1 | ||
return 1 if counter > 0 else 0 | ||
|
||
return _does_contain_bad_words |
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,12 +1,16 @@ | ||
from git_quality_check.utils import sample, are_coupled | ||
from git_quality_check.utils import sample, contains | ||
|
||
|
||
def count_coupled(branches, main_branches): | ||
branches, count = sample(branches, 10) | ||
branches.extend(main_branches) | ||
count += len(main_branches) | ||
counter = 0 | ||
max_counter = 0 | ||
for bA in branches: | ||
for bB in branches: | ||
counter += 1 if are_coupled(bA, bB) else 0 | ||
return counter / count * 100 | ||
if not bA == bB: | ||
print(bA, bB, contains(bA, bB)) | ||
counter += 1 if contains(bA, bB) else 0 | ||
max_counter += 1 | ||
return counter / max_counter * 100 |
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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from git_quality_check.indicators.commits import does_contain_bad_words | ||
|
||
|
||
def test(): | ||
bad_words = ["bad", "word"] | ||
counter = does_contain_bad_words(bad_words) | ||
log = "I am a very bad bad word" | ||
assert counter(log) == 1 | ||
log = "I am a good log" | ||
assert counter(log) == 0 |
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,5 +1,15 @@ | ||
import pytest | ||
from git_quality_check.indicators.commits import is_empty_body | ||
|
||
|
||
def test(): | ||
assert True == False | ||
@pytest.mark.parametrize("log", ["", "commit 1234455"]) | ||
def test_is_empty_body(log): | ||
assert is_empty_body(log) == 1 | ||
|
||
|
||
def test_is_not_empty_body(): | ||
log = """commit 7a1e2a6a76e6967bde14e95900996ca17811de47 (origin/gc/pytest) | ||
Author: gcattan <gregoire.cattan@ibm.com> | ||
Date: 2022-04-17 | ||
remove dependencies""" | ||
assert is_empty_body(log) == 0 |
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,5 +1,12 @@ | ||
import pytest | ||
from git_quality_check.indicators.commits import is_test_commit | ||
|
||
|
||
def test(): | ||
assert True == False | ||
@pytest.mark.parametrize("log", ["test", "testing", "test it", "I am testing it"]) | ||
def test_is_test_commit(log): | ||
assert is_test_commit(log) == 1 | ||
|
||
|
||
def test_is_not_test_commit(): | ||
log = """Tset""" | ||
assert is_test_commit(log) == 0 |
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,5 +1,6 @@ | ||
import pytest | ||
from git_quality_check.indicators.commits import not_a_squashed_commit | ||
|
||
|
||
def test(): | ||
assert True == False | ||
assert not_a_squashed_commit("PR(#7)") == False | ||
assert not_a_squashed_commit("I am not squased") == True |
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,5 +1,6 @@ | ||
import pytest | ||
from git_quality_check.indicators.counters import count_coupled | ||
|
||
|
||
def test(): | ||
assert True == False | ||
assert count_coupled(["origin/update-readme"], ["origin/master"]) == 50 | ||
assert count_coupled(["origin/test-action"], ["origin/formatter"]) == 0 |
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,5 +1,5 @@ | ||
import pytest | ||
from git_quality_check.indicators.counters import count_old_branches | ||
|
||
|
||
def test(): | ||
assert True == False | ||
assert count_old_branches(["origin/gc/pytest_utils", "origin/update-readme"]) == 50 |
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,5 +1,18 @@ | ||
import pytest | ||
from git_quality_check.indicators.counters import process_logs | ||
from git_quality_check.indicators.commits import not_a_squashed_commit, is_empty_body | ||
|
||
|
||
def test(): | ||
assert True == False | ||
logs = [ | ||
"""Commit 1234 | ||
Author: | ||
Date: | ||
Test""", | ||
"""Commit 1234 | ||
Author: | ||
Date: | ||
Merge (#5)""", | ||
"", | ||
] | ||
marked_commits = process_logs(logs, [not_a_squashed_commit, is_empty_body]) | ||
assert marked_commits == 50 |
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,5 +1,6 @@ | ||
import pytest | ||
from git_quality_check.scoring import compute_score | ||
|
||
|
||
def test(): | ||
assert True == False | ||
assert compute_score(100, 0, 100, 100) == 0 | ||
assert compute_score(0, 100, 0, 0) == 100 |
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,5 +1,53 @@ | ||
import pytest | ||
import os | ||
from git_quality_check.utils.common import ( | ||
BADWORDS, | ||
MAINBRANCHES, | ||
parse_inputs, | ||
sample, | ||
diff_month, | ||
) | ||
from datetime import datetime | ||
|
||
|
||
def test(): | ||
assert True == False | ||
def test_parse_inputs(): | ||
os.environ[BADWORDS] = "WIP, todo" | ||
os.environ[MAINBRANCHES] = "origin/develop, origin/main" | ||
bad_words, main_branches = parse_inputs() | ||
assert bad_words[0] == "WIP" | ||
assert bad_words[1] == "todo" | ||
assert main_branches[0] == "origin/develop" | ||
assert main_branches[1] == "origin/main" | ||
|
||
|
||
def test_sample_same_size_than_list(): | ||
li = [3, 10, 6, 15, 20] | ||
size = len(li) | ||
sample_list, count = sample(li, size) | ||
assert count == size | ||
for i in range(size): | ||
assert li[i] == sample_list[i] | ||
|
||
|
||
def test_sample_greater_size_than_list(): | ||
li = [3, 10, 6, 15, 20] | ||
size = len(li) | ||
sample_list, count = sample(li, size + 1) | ||
assert count == size | ||
for i in range(size): | ||
assert li[i] == sample_list[i] | ||
|
||
|
||
def test_sample_lower_size_than_list(): | ||
li = [3, 10, 6, 15, 20] | ||
size = len(li) - 1 | ||
sample_list, count = sample(li, size) | ||
assert count == size | ||
for i in range(size): | ||
assert sample_list[i] in li | ||
|
||
|
||
def test_diff_months(): | ||
date1 = datetime(2022, 8, 1) | ||
date2 = datetime(2023, 8, 1) | ||
assert diff_month(date1, date2) == 12 | ||
assert diff_month(date2, date1) == 12 |
Oops, something went wrong.