Skip to content

Commit

Permalink
some more unit-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grabin-dev committed Apr 2, 2020
1 parent fc3fdc3 commit a07d1f5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
14 changes: 9 additions & 5 deletions demisto_sdk/commands/lint/linter.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,18 @@ def _gather_facts(self, modules: dict) -> bool:
elif self._pkg_lint_status["pack_type"] == TYPE_PWSH:
# Get lint files
lint_files = set(self._pack_abs_dir.glob(["*.ps1", "!*Tests.ps1", "CommonServerPowerShell.ps1", "demistomock.ps1'"], flags=NEGATE))
if 'commonserver' in self._pack_abs_dir.name.lower() and self._pkg_lint_status["pack_type"] == TYPE_PWSH:
self._facts["lint_files"] = [Path(self._pack_abs_dir / 'CommonServerPowerShell.ps1')]
if 'commonserver' in self._pack_abs_dir.name.lower():
if self._pkg_lint_status["pack_type"] == TYPE_PWSH:
self._facts["lint_files"] = [Path(self._pack_abs_dir / 'CommonServerPowerShell.ps1')]
else:
test_modules = {self._pack_abs_dir / module.name for module in modules.keys()}
lint_files = lint_files.difference(test_modules)
self._facts["lint_files"] = list(lint_files)
for lint_file in self._facts["lint_files"]:
logger.info(f"{log_prompt} - Lint file {lint_file}")
if self._facts["lint_files"]:
for lint_file in self._facts["lint_files"]:
logger.info(f"{log_prompt} - Lint file {lint_file}")
else:
logger.info(f"{log_prompt} - Lint files not found")

return False

Expand Down Expand Up @@ -424,7 +428,7 @@ def _run_lint_on_docker_image(self, no_pylint: list, no_test: bool, no_pwsh_anal
keep_container=keep_container)

if (exit_code != RERUN or trial == 2) and exit_code:
self._pkg_lint_status["exit_code"] += EXIT_CODES[check]
self._pkg_lint_status["exit_code"] |= EXIT_CODES[check]
status[f"{check}_errors"] = output
break
elif exit_code != RERUN:
Expand Down
12 changes: 12 additions & 0 deletions demisto_sdk/commands/lint/tests/linter_manager_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from demisto_sdk.commands.common.constants import TYPE_PYTHON, TYPE_PWSH
import pytest
from unittest.mock import patch


@patch('builtins.print')
@pytest.mark.parametrize(argnames="return_exit_code, skipped_code, pkgs_type",
argvalues=[(0b0, 0b0, [TYPE_PWSH, TYPE_PYTHON])])
def test_report_pass_lint_checks(mocker, return_exit_code: int, skipped_code: int, pkgs_type: list):
from demisto_sdk.commands.lint import lint_manager
lint_manager.LintManager.report_pass_lint_checks(return_exit_code, skipped_code, pkgs_type)
assert mocker.call_count == 8

0 comments on commit a07d1f5

Please sign in to comment.