Adding code to check if the all switch is called (#1603)

This commit is contained in:
Daniel W. Anner 2023-09-05 15:39:21 -04:00 committed by GitHub
parent 7757967161
commit b25e45e1b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 3 deletions

View File

@ -3,4 +3,5 @@ pre-commit==3.3.3
pytest==7.4.0
PyYAML==6.0.1
yamllint==1.32.0
gitpython==3.1.32
gitpython==3.1.32
psutil==5.9.5

View File

@ -1,4 +1,4 @@
from test_configuration import COMPONENT_TYPES, IMAGE_FILETYPES, SCHEMAS, KNOWN_SLUGS, ROOT_DIR, USE_LOCAL_KNOWN_SLUGS, NETBOX_DT_LIBRARY_URL, KNOWN_MODULES, USE_UPSTREAM_DIFF
from test_configuration import COMPONENT_TYPES, IMAGE_FILETYPES, SCHEMAS, KNOWN_SLUGS, ROOT_DIR, USE_LOCAL_KNOWN_SLUGS, NETBOX_DT_LIBRARY_URL, KNOWN_MODULES, USE_UPSTREAM_DIFF, PRECOMMIT_ALL_SWITCHES
import pickle_operations
from yaml_loader import DecimalSafeLoader
from device_types import DeviceType, ModuleType, verify_filename, validate_components
@ -7,6 +7,7 @@ import glob
import json
import os
import tempfile
import psutil
from urllib.request import urlopen
import pytest
@ -105,7 +106,11 @@ def test_environment():
if definition_files:
pytest.skip("No changes to definition files found.")
if USE_UPSTREAM_DIFF:
EVALUATE_ALL = False
if any(x in PRECOMMIT_ALL_SWITCHES for x in psutil.Process(os.getppid()).cmdline()):
EVALUATE_ALL = True
if USE_UPSTREAM_DIFF and not EVALUATE_ALL:
definition_files = _get_diff_from_upstream()
else:
definition_files = _get_definition_files()
@ -120,6 +125,7 @@ else:
KNOWN_SLUGS = pickle_operations.read_pickle_data(f'{temp_dir.name}/tests/known-slugs.pickle')
KNOWN_MODULES = pickle_operations.read_pickle_data(f'{temp_dir.name}/tests/known-modules.pickle')
@pytest.mark.parametrize(('file_path', 'schema'), definition_files)
def test_definitions(file_path, schema):
"""

View File

@ -21,6 +21,11 @@ COMPONENT_TYPES = (
'module-bays',
)
PRECOMMIT_ALL_SWITCHES = [
'-a',
'--all-files'
]
ROOT_DIR = os.path.abspath(os.path.join(os.path.dirname( __file__ ), '..'))
KNOWN_SLUGS = set()