From b976d6e82999025ceeec17a29d01f0abe22bcf95 Mon Sep 17 00:00:00 2001 From: gcattan Date: Sun, 10 Jul 2022 21:05:45 +0200 Subject: [PATCH] test skeleton for test_git --- git_quality_check/utils/common.py | 34 +++++++++++++++---------------- git_quality_check/utils/git.py | 2 +- tests/utils/test_git.py | 14 ++++++++++++- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/git_quality_check/utils/common.py b/git_quality_check/utils/common.py index 86988f0..11655f9 100644 --- a/git_quality_check/utils/common.py +++ b/git_quality_check/utils/common.py @@ -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: @@ -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) diff --git a/git_quality_check/utils/git.py b/git_quality_check/utils/git.py index 447fb5a..bd35eb9 100644 --- a/git_quality_check/utils/git.py +++ b/git_quality_check/utils/git.py @@ -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 :] diff --git a/tests/utils/test_git.py b/tests/utils/test_git.py index b12774c..bae5e12 100644 --- a/tests/utils/test_git.py +++ b/tests/utils/test_git.py @@ -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 \ No newline at end of file