Skip to content

Commit

Permalink
test skeleton for test_git
Browse files Browse the repository at this point in the history
  • Loading branch information
gcattan authored Jul 10, 2022
1 parent 30ca401 commit b976d6e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
34 changes: 16 additions & 18 deletions git_quality_check/utils/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
BADWORDS = "INPUT_BADWORDS"
MAINBRANCHES = "INPUT_MAINBRANCHES"

"""
" Gets inputs from environment variables:
" - bad_words: A list of words that should be avoided in commit messages.
" - main_branches: The list of main branches (e.g. master, main or develop)
"""


def parse_inputs():
"""
" Gets inputs from environment variables:
" - bad_words: A list of words that should be avoided in commit messages.
" - main_branches: The list of main branches (e.g. master, main or develop)
"""
bad_words = []
main_branches = []
try:
Expand All @@ -34,21 +34,19 @@ def get_date():
return datetime.today()


# n: number of element to return in the sample
"""
" Computes a sample of size 'n' from a list:
" - if the size of the list is equal or lower than n, returns the list
" - if the size of the list is greater than n, returns a sample of n.
" (some elements might be repetead)
"
" li: the list
" n: expected number of elements in the sample
"
" Returns the tuple (sample, )
"""


def sample(li: list[str], n: int):
"""
" Computes a sample of size 'n' from a list:
" - if the size of the list is equal or lower than n, returns the list
" - if the size of the list is greater than n, returns a sample of n.
" (some elements might be repetead)
"
" li: the list
" n: expected number of elements in the sample
"
" Returns the tuple (sample, )
"""
count = len(li)
if count > n:
li = random.sample(li, n)
Expand Down
2 changes: 1 addition & 1 deletion git_quality_check/utils/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def git_get_branch_date(branch: str):


def remove_first_line(log: str):
if is_valid_log:
if is_valid_log(log):
try:
eol = log.index("\n")
log = log[eol + 1 :]
Expand Down
14 changes: 13 additions & 1 deletion tests/utils/test_git.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
import pytest
from git_quality_check.utils.git import is_old, git_all_branches, are_coupled, git_get_branch_date, remove_first_line

def test_branch_is_old():
assert True == False

def test_branch_are_coupled():
assert True == False

def test():
def test_git_all_branches():
assert True == False

def test_git_get_branch_date():
assert True == False

def test_remove_first_line():
assert True == False

0 comments on commit b976d6e

Please sign in to comment.