GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — powertools-lambda-python/noxfile.py at develop · Goldloli/powertools-lambda-python Expand file tree/ Copy pathnoxfile.pyMore file actions 291 lines (248 loc) · 9.36 KB / Copy pathnoxfile.pyFile metadata and controls291 lines (248 loc) · 9.36 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 # Run nox tests # # usage: # uv run --locked nox --error-on-external-run --reuse-venv=no --non-interactive # # If you want to target a specific Python version, add -p parameter from __future__ import annotations import nox nox.options.default_venv_backend = "uv" PREFIX_TESTS_FUNCTIONAL = "tests/functional" PREFIX_TESTS_UNIT = "tests/unit" def build_and_run_test( session: nox.Session, folders: list, extras: str = "", pytest_args: tuple[str, ...] = (), ) -> None: """ This function is responsible for setting up the testing environment and running the test suite for specific feature. The function performs the following tasks: 1. Installs the required dependencies for executing any test 2. If the `extras` parameter is provided, the function installs the additional dependencies 3. the function runs the pytest command with the specified folders as arguments, executing the test suite. Parameters ---------- session: nox.Session The current Nox session object, which is used to manage the virtual environment and execute commands. folders: List A list of folder paths that contain the test files to be executed. extras: Optional[str] A string representing additional dependencies that should be installed for the test environment. If not provided, the function will install the project with basic dependencies pytest_args: tuple[str, ...] Additional pytest arguments for selecting tests with matching dependencies """ # Required install to execute any test session.install("pytest", "pytest-mock", "pytest_socket", "pytest-asyncio") # Powertools project folder is in the root if extras: session.install(f"./[{extras}]") else: session.install("./") session.run( "python", "-I", "-c", "from importlib.util import find_spec; " "assert find_spec('fastjsonschema') is None, " "'fastjsonschema leaked into the required-dependencies environment'", ) # Execute test in specific folders session.run("pytest", *folders, *pytest_args) @nox.session() def test_with_only_required_packages(session: nox.Session): """Tests that only depends for required libraries""" # Logger # Metrics - Amazon CloudWatch EMF # Metrics - Base provider # Middleware factory without tracer # Typing # Data Class - without codepipeline dataclass # Event Handler without OpenAPI # Batch processor - without pydantic integration build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/logger/required_dependencies/", f"{PREFIX_TESTS_UNIT}/logger/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/metrics/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/middleware_factory/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/typing/required_dependencies/", f"{PREFIX_TESTS_UNIT}/data_classes/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/event_handler/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/batch/required_dependencies/", f"{PREFIX_TESTS_FUNCTIONAL}/kafka_consumer/required_dependencies/", ], pytest_args=("-m", "not requires_validation"), ) @nox.session() def test_with_datadog_as_required_package(session: nox.Session): """Tests that depends on Datadog library""" # Metrics - Datadog build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/metrics/datadog/", ], extras="datadog,aws-sdk", # Datadog library requires boto3 ) @nox.session() def test_with_xray_sdk_as_required_package(session: nox.Session): """Tests that depends on AWS XRAY SDK library""" # Tracer # Middleware factory with tracer build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/tracer/_aws_xray_sdk/", f"{PREFIX_TESTS_FUNCTIONAL}/middleware_factory/_aws_xray_sdk/", ], extras="tracer", ) @nox.session() def test_with_boto3_sdk_as_required_package(session: nox.Session): """Tests that depends on boto3/botocore library""" # Parameters # Feature Flags # Data Class - only codepipeline dataclass # Streaming # Idempotency - DynamoDB persistent layer build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/parameters/_boto3/", f"{PREFIX_TESTS_FUNCTIONAL}/feature_flags/_boto3/", f"{PREFIX_TESTS_UNIT}/data_classes/_boto3/", f"{PREFIX_TESTS_FUNCTIONAL}/streaming/_boto3/", f"{PREFIX_TESTS_FUNCTIONAL}/idempotency/_boto3/", ], extras="aws-sdk", pytest_args=("-m", "not requires_validation"), ) @nox.session() def test_with_fastjsonschema_as_required_package(session: nox.Session): """Tests that depends on fastjsonschema library""" # Validation build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/validator/_fastjsonschema/", f"{PREFIX_TESTS_FUNCTIONAL}/event_handler/required_dependencies/test_api_middlewares.py", ], extras="validation", pytest_args=("-m", "requires_validation"), ) @nox.session() def test_with_aws_encryption_sdk_as_required_package(session: nox.Session): """Tests that depends on aws_encryption_sdk library""" # Data Masking build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/data_masking/_aws_encryption_sdk/", f"{PREFIX_TESTS_UNIT}/data_masking/_aws_encryption_sdk/", f"{PREFIX_TESTS_FUNCTIONAL}/data_masking/required_dependencies/", f"{PREFIX_TESTS_UNIT}/data_masking/required_dependencies/", ], extras="datamasking", ) @nox.session() def test_with_pydantic_required_package(session: nox.Session): """Tests that only depends for Pydantic library v2""" # Event Handler OpenAPI # Parser # Batch Processor with pydantic integration # Kafka Consumer with Output to Pydantic build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/event_handler/_pydantic/", f"{PREFIX_TESTS_FUNCTIONAL}/batch/_pydantic/", f"{PREFIX_TESTS_FUNCTIONAL}/kafka_consumer/_pydantic/", f"{PREFIX_TESTS_UNIT}/parser/_pydantic/", f"{PREFIX_TESTS_UNIT}/event_handler/_pydantic/", ], extras="parser", pytest_args=("-m", "not requires_validation"), ) @nox.session() def test_with_parser_and_validation_required_packages(session: nox.Session): """Validate generated OpenAPI schemas with Parser and Validation dependencies.""" build_and_run_test( session, folders=[f"{PREFIX_TESTS_FUNCTIONAL}/event_handler/_pydantic/"], extras="parser,validation", pytest_args=("-m", "requires_validation"), ) @nox.session() def test_with_boto3_and_validation_required_packages(session: nox.Session): """Test Idempotency combined with the Validation decorator.""" build_and_run_test( session, folders=[f"{PREFIX_TESTS_FUNCTIONAL}/idempotency/_boto3/"], extras="aws-sdk,validation", pytest_args=("-m", "requires_validation"), ) @nox.session() def test_with_boto3_and_pydantic_required_package(session: nox.Session): """Tests that only depends for Boto3 + Pydantic library v2""" # Idempotency with custom serializer build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/idempotency/_pydantic/", ], extras="aws-sdk,parser", ) @nox.session() def test_with_redis_and_boto3_sdk_as_required_package(session: nox.Session): """Tests that depends on Redis library""" # Idempotency - Redis backend # Our Redis tests requires multiprocess library to simulate Race Condition session.install("multiprocess") build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/idempotency/_redis/", ], extras="redis,aws-sdk", ) @nox.session() def test_with_avro_required_package(session: nox.Session): """Tests that only depends the Avro dependency""" # Kafka Consumer with AVRO build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/kafka_consumer/_avro/", ], extras="kafka-consumer-avro", ) @nox.session() def test_with_protobuf_required_package(session: nox.Session): """Tests that only depends the Protobuf dependency""" # Kafka Consumer with PROTOBUF build_and_run_test( session, folders=[ f"{PREFIX_TESTS_FUNCTIONAL}/kafka_consumer/_protobuf/", ], extras="kafka-consumer-protobuf", ) @nox.session() def test_with_auth_required_packages(session: nox.Session): """Verify the Auth utility using only its declared optional dependencies.""" build_and_run_test( session, folders=[f"{PREFIX_TESTS_FUNCTIONAL}/auth_alpha/jwt/"], extras="jwt", ) @nox.session() def test_with_oauth2_required_packages(session: nox.Session): """Verify OAuth token acquisition without JWT or cryptography dependencies.""" build_and_run_test( session, folders=[f"{PREFIX_TESTS_FUNCTIONAL}/auth_alpha/oauth2/"], extras="oauth2", ) |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |