Coverage for netbox_data_import/preview_limits.py: 100.00%

7 statements  

« prev     ^ index     » next       coverage.py v7.17.0, created at 2026-10-30 09:47 +0000

1# SPDX-License-Identifier: Apache-2.0 

2# SPDX-FileCopyrightText: 2026 Marcin Zieba <marcinpsk@gmail.com> 

3"""Shared startup and runtime validation of the preview storage limit.""" 

4 

5from typing import Any 

6 

7MAX_PLAN_BYTES = 64 * 1024 * 1024 

8 

9 

10class InvalidPreviewConfiguration(ValueError): 

11 """The deployment's preview storage limit cannot be used.""" 

12 

13 

14def preview_plan_byte_limit(value: Any = MAX_PLAN_BYTES) -> int: 

15 """Return a positive byte limit within the coordinator's storage ceiling.""" 

16 if type(value) is not int or not 1 <= value <= MAX_PLAN_BYTES: 

17 raise InvalidPreviewConfiguration(f"preview_max_plan_bytes must be an integer from 1 to {MAX_PLAN_BYTES}.") 

18 return value