Skip to content

Commit

Permalink
fix depreaction and replace freezegun package
Browse files Browse the repository at this point in the history
  • Loading branch information
gruebel committed Oct 9, 2023
1 parent e85ec07 commit a198f31
Show file tree
Hide file tree
Showing 16 changed files with 84 additions and 45 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pr-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,7 @@ jobs:
pipenv --rm || true
pipenv --python ${{ matrix.python }}
if [ '${{ matrix.python }}' == '3.12' ]; then
pipenv run pip install -U setuptools pip
if [[ '${{ matrix.python }}' == '3.12' ]]; then
pipenv run pip install aiohttp==3.9.0b0
fi
Expand Down
3 changes: 1 addition & 2 deletions Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ pytest-xdist = "*"
pytest-asyncio = "*"
pytest-cov = "*"
pytest-mock = "*"
mock = "*"
coverage ="==5.5"
coverage-badge = "*"
bandit = "*"
Expand All @@ -36,7 +35,7 @@ dlint = "*"
mypy = "*"
flake8-bugbear = "*"
parameterized = "*"
freezegun = "*"
time-machine = "*"
boto3-stubs-lite = {extras = ["s3"], version = "*"}

[packages]
Expand Down
80 changes: 63 additions & 17 deletions Pipfile.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions checkov/common/output/gitlab_sast.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from datetime import datetime
from datetime import datetime, timezone
from typing import TYPE_CHECKING, Any
from uuid import uuid4

Expand Down Expand Up @@ -37,7 +37,7 @@ def create_sast_json(self) -> dict[str, Any]:
}

def _create_scan(self) -> dict[str, Any]:
current_datetime = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S")
current_datetime = datetime.now(timezone.utc).strftime("%Y-%m-%dT%H:%M:%S")
scanner = {
"id": "checkov",
"name": "Checkov",
Expand Down
2 changes: 1 addition & 1 deletion tests/common/checks/test_base_check.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import unittest

import mock
from unittest import mock
from parameterized import parameterized

from checkov.common.checks.base_check import BaseCheck
Expand Down
6 changes: 3 additions & 3 deletions tests/common/output/test_spdx.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from freezegun import freeze_time
from time_machine import travel

from checkov.common.bridgecrew.check_type import CheckType
from checkov.common.output.extra_resource import ExtraResource
Expand All @@ -7,7 +7,7 @@
from checkov.common.sca.output import create_report_cve_record


@freeze_time("2022-12-24")
@travel("2022-12-24")
def test_sca_package_output():
# given
rootless_file_path = "requirements.txt"
Expand Down Expand Up @@ -85,7 +85,7 @@ def test_sca_package_output():
"## Creation Information\n",
"Creator: Tool: checkov\n",
"Creator: Organization: bridgecrew ([email protected])\n",
"Created: 2022-12-24T00:00:00+00:00Z\n",
"Created: 2022-12-23T23:00:00+00:00Z\n",
"\n",
"## Package Information\n",
"PackageName: django\n",
Expand Down
2 changes: 1 addition & 1 deletion tests/common/test_resource_code_logger_filter.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import logging
import mock
from unittest import mock

from checkov.common.resource_code_logger_filter import add_resource_code_filter_to_logger

Expand Down
4 changes: 2 additions & 2 deletions tests/github/checks/test_python_policies.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from pathlib import Path

import pytest
from freezegun import freeze_time
from time_machine import travel

from checkov.github.runner import Runner
from checkov.runner_filter import RunnerFilter
Expand Down Expand Up @@ -45,7 +45,7 @@ def test_GithubRequire2Approvals():
run_check(base_path=BASE_DIR / "branch_security", check="GithubRequire2Approvals")


@freeze_time("2022-12-05")
@travel("2022-12-05")
def test_GithubDisallowInactiveBranch60Days():
run_check(base_path=BASE_DIR / "branch_security", check="GithubDisallowInactiveBranch60Days")

Expand Down
2 changes: 1 addition & 1 deletion tests/kustomize/test_runner.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import os
import mock
import unittest
from pathlib import Path
from unittest import mock

from checkov.common.bridgecrew.check_type import CheckType
from checkov.common.bridgecrew.severities import Severities, BcSeverities
Expand Down
3 changes: 1 addition & 2 deletions tests/kustomize/test_runner_image_referencer.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import annotations

import os
import sys
from pathlib import Path
from unittest import mock

import mock
import pytest
from pytest_mock import MockerFixture

Expand Down
3 changes: 2 additions & 1 deletion tests/secrets/test_secrets_verification.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from __future__ import annotations

import os
from unittest import mock

import mock
import pytest
import responses

Expand Down
2 changes: 1 addition & 1 deletion tests/secrets/test_secrets_verification_suppressions.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import os
from unittest import mock

import mock
import responses
from checkov.common.models.enums import CheckResult

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import os
import unittest
from pathlib import Path

import mock
from unittest import mock

from checkov.runner_filter import RunnerFilter
from checkov.terraform.checks.resource.gcp.GoogleComputeFirewallUnrestrictedIngress22 import check
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ def test_get_cached_jsonpath_statement(mocker: MockerFixture):
assert len(BaseAttributeSolver.jsonpath_parsed_statement_cache) == 1

# patch jsonpath_ng.parse to be able to check it was really not called again and the cache was properly used
with mocker.patch("checkov.common.checks_infra.solvers.attribute_solvers.base_attribute_solver.parse", side_effect=jsonpath_parse_mock):
solver_2._get_cached_jsonpath_statement(statement=statement)
mocker.patch("checkov.common.checks_infra.solvers.attribute_solvers.base_attribute_solver.parse", side_effect=jsonpath_parse_mock)
solver_2._get_cached_jsonpath_statement(statement=statement)

# then
assert len(BaseAttributeSolver.jsonpath_parsed_statement_cache) == 1
Expand Down
4 changes: 1 addition & 3 deletions tests/terraform/graph/graph_builder/test_local_graph.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import os
from pathlib import Path
from unittest import TestCase

import mock
import json
from unittest import mock

from checkov.common.graph.db_connectors.networkx.networkx_db_connector import NetworkxConnector
from checkov.common.graph.graph_builder import EncryptionValues, EncryptionTypes
Expand Down
4 changes: 1 addition & 3 deletions tests/terraform/runner/test_plan_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
from collections import defaultdict
from copy import deepcopy
from pathlib import Path


from typing import Dict, Any
from unittest import mock

import mock
from parameterized import parameterized_class

# do not remove - prevents circular import
Expand Down

0 comments on commit a198f31

Please sign in to comment.