hicelltek-tac 1.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,25 @@
1
+ MIT License (SDK Client Code Only)
2
+
3
+ Copyright (c) 2026 HiCellTek (Entreprise Individuelle, SIREN 882 716 228)
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software client wrapper and associated documentation files (the "Software"),
7
+ to deal in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ DATABASE & API RESPONSE NOTICE:
16
+ This MIT license covers solely the Python HTTP client source code in this repository.
17
+ All API responses, TAC mappings, and radio specifications returned by the HiCellTek
18
+ API remain strictly governed by the HiCellTek API Terms of Service
19
+ (https://hicelltek.com/en/api-terms/) and EU sui generis database rights
20
+ (Directive 96/9/EC). Enumeration, scraping, public exposure, and redistribution
21
+ of API responses are strictly prohibited.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: hicelltek-tac
3
+ Version: 1.0.0
4
+ Summary: Official zero-dependency Python client for the HiCellTek IMEI & TAC Intelligence REST API (GSMA TS.06 RBI validation, 4G/5G bands, CA combos, eSIM, VoLTE & 2G/3G sunset readiness).
5
+ Author-email: TAKWA SEBAI <takwa.sebai@hicelltek.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://hicelltek.com/en/imei-api/
8
+ Project-URL: Documentation, https://hicelltek.com/en/api-documentation/
9
+ Project-URL: OpenAPI Schema, https://imei.hicelltek.com/api/v1/openapi.json
10
+ Project-URL: Terms of Service, https://hicelltek.com/en/api-terms/
11
+ Project-URL: Repository, https://github.com/tsebai/hicelltek-tac-python
12
+ Keywords: imei,tac,gsma,3gpp,5g,lte,esim,volte,mvno,telecom,iot
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Telecommunications Industry
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Communications :: Telephony
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Dynamic: license-file
30
+
31
+ # hicelltek-tac · Python Client for the HiCellTek IMEI & TAC Intelligence API
32
+
33
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24796697.svg)](https://doi.org/10.5281/zenodo.24796697)
34
+
35
+
36
+ Zero-dependency, typed Python client for the **[HiCellTek IMEI & TAC Intelligence REST API](https://hicelltek.com/en/imei-api/)** (`https://imei.hicelltek.com/api`).
37
+
38
+ Built for **MVNOs, Travel eSIM platforms, Mobile Network Operators, M2M/IoT fleet operators, MDM tools, and B2B device marketplaces**.
39
+
40
+ ## Key Capabilities
41
+
42
+ - **Local GSMA / 3GPP Input Validation (Zero Network Call):** Validates 8-digit TACs and verifies 15-digit IMEI Luhn check digits (`3GPP TS 23.003`) locally before sending HTTP requests.
43
+ - **Single & Batch TAC Lookup (`/v1/tac/lookup`, `/v1/tac/batch`):** Resolves brand, model, chipset, device type (`smartphone`, `iot_module`, `pos_terminal`, `automotive_tcu`, `cpe_router`), 4G LTE / 5G NR bands, Carrier Aggregation combinations, and GSMA TS.06 RBI reason codes (`not_in_database`, `test_me_rbi`, `unallocated_rbi`).
44
+ - **Travel eSIM, VoLTE & 2G/3G Sunset Readiness (`/v1/readiness/{imei}/{country}`):** Evaluates eSIM capability, TAC-level regional hardware variants (`EU`, `US`, `CN`, `JP`, `KR`), VoLTE provenance (`volte_source`), VoLTE Emergency (112/911/000), VoLTE Roaming (S8HR/LBO), and IoT RAT taxonomy (`LTE-M`, `NB-IoT`, `Cat-1bis`, `5G RedCap`, `IoT-NTN`) across **164 countries and 582 operators**.
45
+ - **Zero External Dependencies:** Uses only the Python 3.9+ standard library (`urllib.request`, `json`). Runs cleanly in AWS Lambda, Scaleway Functions, Docker slim images, and air-gapped CI pipelines.
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install hicelltek-tac
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ Request a 14-day B2B evaluation key (work email required) at **https://hicelltek.com/en/imei-api/** and export it as `HICELLTEK_API_KEY`:
56
+
57
+ ```python
58
+ from hicelltek_tac import HiCellTekTacClient, is_valid_imei_luhn, extract_tac
59
+
60
+ # 1. Offline 3GPP TS 23.003 Luhn check & TAC extraction (zero quota used)
61
+ assert is_valid_imei_luhn("354071151234568") is False
62
+ tac = extract_tac("35407115") # -> "35407115"
63
+
64
+ # 2. Live API lookup (reads HICELLTEK_API_KEY from environment by default)
65
+ client = HiCellTekTacClient()
66
+
67
+ device = client.lookup("35407115")
68
+ if device["found"]:
69
+ print(device["brand"]["name"], device["model"], device.get("chipset"))
70
+
71
+ # 3. Travel eSIM & 2G/3G Sunset Readiness in France (Pro / Business tier)
72
+ readiness = client.check_readiness("35407115", country="FR")
73
+ print(readiness["readiness"]["overall_status"], readiness["readiness"]["warnings"])
74
+ ```
75
+
76
+ ## Error Handling & Anti-Retry Discipline
77
+
78
+ When a TAC is not found (`HTTP 404`), the client returns the structured `TacNotFoundResponse` dictionary (`found: False`, `valid_tac`, `reason`) instead of raising an exception, so your application can inspect `reason`:
79
+
80
+ - `unallocated_rbi`: Reporting Body Identifier never allocated by the GSMA. **Never retry.**
81
+ - `test_me_rbi`: 3GPP Test ME prefix (`00` or `02` to `09`) reserved for conformance/lab equipment.
82
+ - `not_in_database`: Valid GSMA RBI prefix currently absent from the catalogue.
83
+
84
+ Authentication (`401`), plan entitlement (`403`), validation (`422`), and rate-limit (`429`) errors raise `HiCellTekApiError` with `.status_code` and `.payload`.
85
+
86
+ ## Related Telecom Tools by HiCellTek
87
+
88
+ - **IMEI & TAC API Documentation & Pricing:** https://hicelltek.com/en/imei-api/
89
+ - **Free Web TAC Lookup:** https://hicelltek.com/en/tac-lookup/
90
+ - **Free Online 3GPP RRC & NAS Decoder (2G to 5G Rel-19):** https://hicelltek.com/en/decoder/
91
+ - **Android 2G/3G/4G/5G Layer 3 Drive Test & Post-Processing Suite:** https://hicelltek.com/en/drive-test-tool-android/
92
+
93
+ ## Acceptable Use & Legal Notice
94
+
95
+ This client code is licensed under MIT, while all API responses and catalogue records remain strictly governed by the **[HiCellTek API Terms of Service](https://hicelltek.com/en/api-terms/)** (B2B internal operational use only; TAC enumeration, scraping, public checker exposure, and redistribution are strictly prohibited; TAC lookup is not a stolen-device or carrier blacklist registry).
@@ -0,0 +1,65 @@
1
+ # hicelltek-tac · Python Client for the HiCellTek IMEI & TAC Intelligence API
2
+
3
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24796697.svg)](https://doi.org/10.5281/zenodo.24796697)
4
+
5
+
6
+ Zero-dependency, typed Python client for the **[HiCellTek IMEI & TAC Intelligence REST API](https://hicelltek.com/en/imei-api/)** (`https://imei.hicelltek.com/api`).
7
+
8
+ Built for **MVNOs, Travel eSIM platforms, Mobile Network Operators, M2M/IoT fleet operators, MDM tools, and B2B device marketplaces**.
9
+
10
+ ## Key Capabilities
11
+
12
+ - **Local GSMA / 3GPP Input Validation (Zero Network Call):** Validates 8-digit TACs and verifies 15-digit IMEI Luhn check digits (`3GPP TS 23.003`) locally before sending HTTP requests.
13
+ - **Single & Batch TAC Lookup (`/v1/tac/lookup`, `/v1/tac/batch`):** Resolves brand, model, chipset, device type (`smartphone`, `iot_module`, `pos_terminal`, `automotive_tcu`, `cpe_router`), 4G LTE / 5G NR bands, Carrier Aggregation combinations, and GSMA TS.06 RBI reason codes (`not_in_database`, `test_me_rbi`, `unallocated_rbi`).
14
+ - **Travel eSIM, VoLTE & 2G/3G Sunset Readiness (`/v1/readiness/{imei}/{country}`):** Evaluates eSIM capability, TAC-level regional hardware variants (`EU`, `US`, `CN`, `JP`, `KR`), VoLTE provenance (`volte_source`), VoLTE Emergency (112/911/000), VoLTE Roaming (S8HR/LBO), and IoT RAT taxonomy (`LTE-M`, `NB-IoT`, `Cat-1bis`, `5G RedCap`, `IoT-NTN`) across **164 countries and 582 operators**.
15
+ - **Zero External Dependencies:** Uses only the Python 3.9+ standard library (`urllib.request`, `json`). Runs cleanly in AWS Lambda, Scaleway Functions, Docker slim images, and air-gapped CI pipelines.
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ pip install hicelltek-tac
21
+ ```
22
+
23
+ ## Quick Start
24
+
25
+ Request a 14-day B2B evaluation key (work email required) at **https://hicelltek.com/en/imei-api/** and export it as `HICELLTEK_API_KEY`:
26
+
27
+ ```python
28
+ from hicelltek_tac import HiCellTekTacClient, is_valid_imei_luhn, extract_tac
29
+
30
+ # 1. Offline 3GPP TS 23.003 Luhn check & TAC extraction (zero quota used)
31
+ assert is_valid_imei_luhn("354071151234568") is False
32
+ tac = extract_tac("35407115") # -> "35407115"
33
+
34
+ # 2. Live API lookup (reads HICELLTEK_API_KEY from environment by default)
35
+ client = HiCellTekTacClient()
36
+
37
+ device = client.lookup("35407115")
38
+ if device["found"]:
39
+ print(device["brand"]["name"], device["model"], device.get("chipset"))
40
+
41
+ # 3. Travel eSIM & 2G/3G Sunset Readiness in France (Pro / Business tier)
42
+ readiness = client.check_readiness("35407115", country="FR")
43
+ print(readiness["readiness"]["overall_status"], readiness["readiness"]["warnings"])
44
+ ```
45
+
46
+ ## Error Handling & Anti-Retry Discipline
47
+
48
+ When a TAC is not found (`HTTP 404`), the client returns the structured `TacNotFoundResponse` dictionary (`found: False`, `valid_tac`, `reason`) instead of raising an exception, so your application can inspect `reason`:
49
+
50
+ - `unallocated_rbi`: Reporting Body Identifier never allocated by the GSMA. **Never retry.**
51
+ - `test_me_rbi`: 3GPP Test ME prefix (`00` or `02` to `09`) reserved for conformance/lab equipment.
52
+ - `not_in_database`: Valid GSMA RBI prefix currently absent from the catalogue.
53
+
54
+ Authentication (`401`), plan entitlement (`403`), validation (`422`), and rate-limit (`429`) errors raise `HiCellTekApiError` with `.status_code` and `.payload`.
55
+
56
+ ## Related Telecom Tools by HiCellTek
57
+
58
+ - **IMEI & TAC API Documentation & Pricing:** https://hicelltek.com/en/imei-api/
59
+ - **Free Web TAC Lookup:** https://hicelltek.com/en/tac-lookup/
60
+ - **Free Online 3GPP RRC & NAS Decoder (2G to 5G Rel-19):** https://hicelltek.com/en/decoder/
61
+ - **Android 2G/3G/4G/5G Layer 3 Drive Test & Post-Processing Suite:** https://hicelltek.com/en/drive-test-tool-android/
62
+
63
+ ## Acceptable Use & Legal Notice
64
+
65
+ This client code is licensed under MIT, while all API responses and catalogue records remain strictly governed by the **[HiCellTek API Terms of Service](https://hicelltek.com/en/api-terms/)** (B2B internal operational use only; TAC enumeration, scraping, public checker exposure, and redistribution are strictly prohibited; TAC lookup is not a stolen-device or carrier blacklist registry).
@@ -0,0 +1,59 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "hicelltek-tac"
7
+ version = "1.0.0"
8
+ description = "Official zero-dependency Python client for the HiCellTek IMEI & TAC Intelligence REST API (GSMA TS.06 RBI validation, 4G/5G bands, CA combos, eSIM, VoLTE & 2G/3G sunset readiness)."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "TAKWA SEBAI", email = "takwa.sebai@hicelltek.com" }
14
+ ]
15
+ keywords = [
16
+ "imei",
17
+ "tac",
18
+ "gsma",
19
+ "3gpp",
20
+ "5g",
21
+ "lte",
22
+ "esim",
23
+ "volte",
24
+ "mvno",
25
+ "telecom",
26
+ "iot"
27
+ ]
28
+ classifiers = [
29
+ "Development Status :: 5 - Production/Stable",
30
+ "Intended Audience :: Developers",
31
+ "Intended Audience :: Telecommunications Industry",
32
+ "License :: OSI Approved :: MIT License",
33
+ "Programming Language :: Python :: 3",
34
+ "Programming Language :: Python :: 3.9",
35
+ "Programming Language :: Python :: 3.10",
36
+ "Programming Language :: Python :: 3.11",
37
+ "Programming Language :: Python :: 3.12",
38
+ "Programming Language :: Python :: 3.13",
39
+ "Topic :: Communications :: Telephony",
40
+ "Topic :: Software Development :: Libraries :: Python Modules",
41
+ "Typing :: Typed"
42
+ ]
43
+
44
+ [project.urls]
45
+ Homepage = "https://hicelltek.com/en/imei-api/"
46
+ Documentation = "https://hicelltek.com/en/api-documentation/"
47
+ "OpenAPI Schema" = "https://imei.hicelltek.com/api/v1/openapi.json"
48
+ "Terms of Service" = "https://hicelltek.com/en/api-terms/"
49
+ Repository = "https://github.com/tsebai/hicelltek-tac-python"
50
+
51
+ [tool.setuptools.packages.find]
52
+ where = ["src"]
53
+
54
+ [tool.setuptools.package-data]
55
+ hicelltek_tac = ["py.typed"]
56
+
57
+ [tool.mypy]
58
+ strict = true
59
+ python_version = "3.11"
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,45 @@
1
+ """Official Python client for the HiCellTek IMEI & TAC Intelligence API.
2
+
3
+ Author: TAKWA SEBAI (HiCellTek)
4
+ """
5
+
6
+ from .client import (
7
+ DEFAULT_BASE_URL,
8
+ MAX_BATCH_SIZE,
9
+ HiCellTekApiError,
10
+ HiCellTekTacClient,
11
+ classify_tac_prefix,
12
+ compute_luhn_check_digit,
13
+ extract_tac,
14
+ is_valid_imei_luhn,
15
+ )
16
+ from .types import (
17
+ BrandInfo,
18
+ NotFoundReason,
19
+ RbiClassification,
20
+ ReadinessStatus,
21
+ RegionalVariant,
22
+ SupportedLanguage,
23
+ TacLookupHit,
24
+ TacLookupMiss,
25
+ )
26
+
27
+ __all__ = [
28
+ "BrandInfo",
29
+ "DEFAULT_BASE_URL",
30
+ "HiCellTekApiError",
31
+ "HiCellTekTacClient",
32
+ "MAX_BATCH_SIZE",
33
+ "NotFoundReason",
34
+ "RbiClassification",
35
+ "ReadinessStatus",
36
+ "RegionalVariant",
37
+ "SupportedLanguage",
38
+ "TacLookupHit",
39
+ "TacLookupMiss",
40
+ "classify_tac_prefix",
41
+ "compute_luhn_check_digit",
42
+ "extract_tac",
43
+ "is_valid_imei_luhn",
44
+ ]
45
+ __version__ = "1.0.0"
@@ -0,0 +1,286 @@
1
+ """Zero-dependency HTTP client and offline 3GPP TS 23.003 / GSMA TS.06 validators.
2
+
3
+ Author: TAKWA SEBAI (HiCellTek)
4
+ """
5
+
6
+ from __future__ import annotations
7
+
8
+ import json
9
+ import os
10
+ import re
11
+ import urllib.error
12
+ import urllib.parse
13
+ import urllib.request
14
+ from typing import Any, Dict, List, Mapping, Optional, Sequence, Union
15
+
16
+ from .types import RbiClassification, SupportedLanguage, TacLookupHit, TacLookupMiss
17
+
18
+ DEFAULT_BASE_URL = "https://imei.hicelltek.com/api"
19
+ MAX_BATCH_SIZE = 100
20
+ SUPPORTED_LANGUAGES = ("en", "fr", "es", "ar")
21
+
22
+ # 3GPP TS 23.003 / GSMA TS.06 Reporting Body Identifiers reserved for Test Mobile Equipment
23
+ _TEST_ME_RBI_PREFIXES = frozenset({"00", "02", "03", "04", "05", "06", "07", "08", "09"})
24
+ _SEPARATORS_RE = re.compile(r"[\s\-]+")
25
+ _COUNTRY_RE = re.compile(r"^[A-Za-z]{2}$")
26
+
27
+ TacLookupResult = Union[TacLookupHit, TacLookupMiss, Dict[str, Any]]
28
+
29
+
30
+ class HiCellTekApiError(Exception):
31
+ """Raised on HTTP 401, 403, 422, 429, or 5xx responses from the HiCellTek API."""
32
+
33
+ def __init__(
34
+ self,
35
+ status_code: int,
36
+ message: str,
37
+ payload: Optional[Mapping[str, Any]] = None,
38
+ *,
39
+ retry_after_seconds: Optional[int] = None,
40
+ ) -> None:
41
+ super().__init__(f"HTTP {status_code}: {message}")
42
+ self.status_code = status_code
43
+ self.message = message
44
+ self.payload: Dict[str, Any] = dict(payload) if payload is not None else {}
45
+ self.retry_after_seconds = retry_after_seconds
46
+
47
+
48
+ def _normalize_digits(value: str) -> str:
49
+ if not isinstance(value, str):
50
+ raise TypeError("Identifier must be provided as a string.")
51
+ return _SEPARATORS_RE.sub("", value.strip())
52
+
53
+
54
+ def compute_luhn_check_digit(first_14_digits: str) -> str:
55
+ """Compute the 15th IMEI check digit per 3GPP TS 23.003 Annex B (Luhn mod-10)."""
56
+ cleaned = _normalize_digits(first_14_digits)
57
+ if len(cleaned) != 14 or not cleaned.isascii() or not cleaned.isdigit():
58
+ raise ValueError("Expected exactly 14 ASCII digits to compute the IMEI check digit.")
59
+
60
+ checksum = 0
61
+ for index, char in enumerate(cleaned):
62
+ digit = ord(char) - 48
63
+ if index % 2 == 1:
64
+ doubled = digit * 2
65
+ checksum += doubled - 9 if doubled > 9 else doubled
66
+ else:
67
+ checksum += digit
68
+ return str((10 - (checksum % 10)) % 10)
69
+
70
+
71
+ def is_valid_imei_luhn(imei: str) -> bool:
72
+ """Return True if *imei* is a 15-digit ASCII string with a valid Luhn check digit."""
73
+ if not isinstance(imei, str):
74
+ return False
75
+ cleaned = _SEPARATORS_RE.sub("", imei.strip())
76
+ if len(cleaned) != 15 or not cleaned.isascii() or not cleaned.isdigit():
77
+ return False
78
+ return compute_luhn_check_digit(cleaned[:14]) == cleaned[14]
79
+
80
+
81
+ def extract_tac(tac_or_imei: str, *, strict_luhn: bool = False) -> str:
82
+ """Validate an 8-digit TAC or 15-digit IMEI and return its 8-digit TAC prefix."""
83
+ cleaned = _normalize_digits(tac_or_imei)
84
+ if len(cleaned) == 8 and cleaned.isascii() and cleaned.isdigit():
85
+ return cleaned
86
+ if len(cleaned) == 15 and cleaned.isascii() and cleaned.isdigit():
87
+ if strict_luhn and not is_valid_imei_luhn(cleaned):
88
+ raise ValueError("15-digit IMEI failed 3GPP TS 23.003 Luhn check digit validation.")
89
+ return cleaned[:8]
90
+ raise ValueError("Expected an 8-digit TAC or a 15-digit IMEI.")
91
+
92
+
93
+ def classify_tac_prefix(tac_or_imei: str) -> RbiClassification:
94
+ """Offline check for 3GPP/GSMA Test ME RBI prefixes ('00' and '02'..'09')."""
95
+ tac = extract_tac(tac_or_imei)
96
+ if tac[:2] in _TEST_ME_RBI_PREFIXES:
97
+ return "test_me_rbi"
98
+ return "commercial_candidate"
99
+
100
+
101
+ def _parse_retry_after(headers: Any) -> Optional[int]:
102
+ if headers is None:
103
+ return None
104
+ raw = headers.get("Retry-After")
105
+ if raw is None:
106
+ return None
107
+ try:
108
+ val = int(str(raw).strip())
109
+ return val if val >= 0 else None
110
+ except ValueError:
111
+ return None
112
+
113
+
114
+ class HiCellTekTacClient:
115
+ """Production REST client for https://imei.hicelltek.com/api (OpenAPI 3.1 v1.6.3).
116
+
117
+ Supports context-manager usage and defaults to privacy-preserving 8-digit TAC
118
+ truncation when given full 15-digit IMEIs on lookup endpoints.
119
+ """
120
+
121
+ def __init__(
122
+ self,
123
+ api_key: Optional[str] = None,
124
+ *,
125
+ base_url: str = DEFAULT_BASE_URL,
126
+ timeout_seconds: float = 10.0,
127
+ ) -> None:
128
+ resolved_key = (api_key if api_key is not None else os.environ.get("HICELLTEK_API_KEY", "")).strip()
129
+ if not resolved_key:
130
+ raise ValueError(
131
+ "Missing API key. Pass api_key='hct_...' or export the HICELLTEK_API_KEY environment variable."
132
+ )
133
+ if not base_url.startswith("https://"):
134
+ raise ValueError("base_url must use HTTPS.")
135
+ if timeout_seconds <= 0:
136
+ raise ValueError("timeout_seconds must be strictly positive.")
137
+
138
+ self._api_key = resolved_key
139
+ self._base_url = base_url.rstrip("/")
140
+ self._timeout = float(timeout_seconds)
141
+
142
+ def __enter__(self) -> HiCellTekTacClient:
143
+ return self
144
+
145
+ def __exit__(self, exc_type: Any, exc: Any, tb: Any) -> None:
146
+ return None
147
+
148
+ def _prepare_identifier(self, value: str, *, send_tac_only: bool, strict_luhn: bool) -> str:
149
+ cleaned = _normalize_digits(value)
150
+ if len(cleaned) == 8 and cleaned.isascii() and cleaned.isdigit():
151
+ return cleaned
152
+ if len(cleaned) == 15 and cleaned.isascii() and cleaned.isdigit():
153
+ if strict_luhn and not is_valid_imei_luhn(cleaned):
154
+ raise ValueError("15-digit IMEI failed 3GPP TS 23.003 Luhn check digit validation.")
155
+ return cleaned[:8] if send_tac_only else cleaned
156
+ raise ValueError("Identifier must be an 8-digit TAC or a 15-digit IMEI.")
157
+
158
+ def _validate_country(self, country: str) -> str:
159
+ if not isinstance(country, str):
160
+ raise TypeError("country must be a 2-letter ISO 3166-1 alpha-2 string.")
161
+ normalized = country.strip().upper()
162
+ if not _COUNTRY_RE.match(normalized):
163
+ raise ValueError("country must be a 2-letter ISO 3166-1 alpha-2 code (for example 'FR' or 'US').")
164
+ return normalized
165
+
166
+ def _validate_lang(self, lang: str) -> SupportedLanguage:
167
+ if lang not in SUPPORTED_LANGUAGES:
168
+ raise ValueError(f"lang must be one of {SUPPORTED_LANGUAGES}.")
169
+ return lang # type: ignore[return-value]
170
+
171
+ def _request(
172
+ self,
173
+ method: str,
174
+ path: str,
175
+ *,
176
+ body: Optional[Mapping[str, Any]] = None,
177
+ return_404_json: bool = False,
178
+ ) -> Dict[str, Any]:
179
+ url = f"{self._base_url}{path}"
180
+ headers = {
181
+ "Accept": "application/json",
182
+ "User-Agent": "hicelltek-tac-python/1.0.0",
183
+ "X-Api-Key": self._api_key,
184
+ }
185
+ encoded_body: Optional[bytes] = None
186
+ if body is not None:
187
+ headers["Content-Type"] = "application/json"
188
+ encoded_body = json.dumps(body, separators=(",", ":")).encode("utf-8")
189
+
190
+ request = urllib.request.Request(url=url, data=encoded_body, headers=headers, method=method)
191
+ try:
192
+ with urllib.request.urlopen(request, timeout=self._timeout) as response:
193
+ raw_bytes = response.read()
194
+ return json.loads(raw_bytes.decode("utf-8")) if raw_bytes else {}
195
+ except urllib.error.HTTPError as exc:
196
+ error_text = exc.read().decode("utf-8", errors="replace") if exc.fp is not None else ""
197
+ parsed_error: Dict[str, Any] = {}
198
+ if error_text:
199
+ try:
200
+ candidate = json.loads(error_text)
201
+ parsed_error = candidate if isinstance(candidate, dict) else {"detail": candidate}
202
+ except json.JSONDecodeError:
203
+ parsed_error = {"raw": error_text}
204
+
205
+ if exc.code == 404 and return_404_json and parsed_error.get("found") is False:
206
+ return parsed_error
207
+
208
+ message = str(parsed_error.get("message") or parsed_error.get("error") or exc.reason)
209
+ raise HiCellTekApiError(
210
+ exc.code,
211
+ message,
212
+ parsed_error,
213
+ retry_after_seconds=_parse_retry_after(exc.headers),
214
+ ) from exc
215
+
216
+ def lookup(
217
+ self,
218
+ query: str,
219
+ *,
220
+ lang: SupportedLanguage = "en",
221
+ send_tac_only: bool = True,
222
+ strict_luhn: bool = False,
223
+ ) -> TacLookupResult:
224
+ """Resolve a single 8-digit TAC or 15-digit IMEI via POST /v1/tac/lookup."""
225
+ checked_lang = self._validate_lang(lang)
226
+ outbound = self._prepare_identifier(query, send_tac_only=send_tac_only, strict_luhn=strict_luhn)
227
+ return self._request(
228
+ "POST",
229
+ "/v1/tac/lookup",
230
+ body={"query": outbound, "lang": checked_lang},
231
+ return_404_json=True,
232
+ )
233
+
234
+ def batch_lookup(
235
+ self,
236
+ queries: Sequence[str],
237
+ *,
238
+ lang: SupportedLanguage = "en",
239
+ send_tac_only: bool = True,
240
+ strict_luhn: bool = False,
241
+ ) -> List[TacLookupResult]:
242
+ """Resolve 1 to 100 TACs or IMEIs in a single request via POST /v1/tac/batch (Pro/Business)."""
243
+ if isinstance(queries, (str, bytes)) or not queries or len(queries) > MAX_BATCH_SIZE:
244
+ raise ValueError(f"queries must be a sequence of 1 to {MAX_BATCH_SIZE} identifiers.")
245
+ checked_lang = self._validate_lang(lang)
246
+ outbound_items = [
247
+ self._prepare_identifier(item, send_tac_only=send_tac_only, strict_luhn=strict_luhn)
248
+ for item in queries
249
+ ]
250
+ response = self._request("POST", "/v1/tac/batch", body={"queries": outbound_items, "lang": checked_lang})
251
+ results = response.get("results", [])
252
+ return list(results) if isinstance(results, list) else []
253
+
254
+ def check_readiness(
255
+ self,
256
+ tac_or_imei: str,
257
+ country: str,
258
+ *,
259
+ send_tac_only: bool = True,
260
+ strict_luhn: bool = False,
261
+ ) -> Dict[str, Any]:
262
+ """Evaluate destination eSIM, VoLTE, and 2G/3G sunset readiness via GET /v1/readiness/{imei}/{country}."""
263
+ outbound = self._prepare_identifier(tac_or_imei, send_tac_only=send_tac_only, strict_luhn=strict_luhn)
264
+ iso_country = self._validate_country(country)
265
+ safe_id = urllib.parse.quote(outbound, safe="")
266
+ return self._request("GET", f"/v1/readiness/{safe_id}/{iso_country}", return_404_json=True)
267
+
268
+ def check_compatibility(self, tac_or_imei: str, country: str) -> Dict[str, Any]:
269
+ """Evaluate 4G/5G band and voice operator compatibility via GET /v1/compatibility/{tac}/{country}."""
270
+ tac8 = extract_tac(tac_or_imei)
271
+ iso_country = self._validate_country(country)
272
+ return self._request("GET", f"/v1/compatibility/{tac8}/{iso_country}", return_404_json=True)
273
+
274
+ def list_countries(self) -> Dict[str, Any]:
275
+ """List all supported countries and operator counts via GET /v1/compatibility/countries."""
276
+ return self._request("GET", "/v1/compatibility/countries")
277
+
278
+ def key_profile(self) -> Dict[str, Any]:
279
+ """Inspect active API key plan, limits, and remaining quota via GET /v1/keys/me."""
280
+ return self._request("GET", "/v1/keys/me")
281
+
282
+ def key_usage(self, days: int = 30) -> Dict[str, Any]:
283
+ """Retrieve daily usage analytics (1 to 90 days) via GET /v1/keys/usage."""
284
+ if isinstance(days, bool) or not isinstance(days, int) or not 1 <= days <= 90:
285
+ raise ValueError("days must be an integer between 1 and 90.")
286
+ return self._request("GET", f"/v1/keys/usage?days={days}")
File without changes
@@ -0,0 +1,48 @@
1
+ """Typed response structures aligned with HiCellTek OpenAPI 3.1 (v1.6.3)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Any, Dict, List, Literal, Optional, TypedDict
6
+
7
+ SupportedLanguage = Literal["en", "fr", "es", "ar"]
8
+ RbiClassification = Literal["commercial_candidate", "test_me_rbi"]
9
+ NotFoundReason = Literal["not_in_database", "test_me_rbi", "unallocated_rbi"]
10
+ ReadinessStatus = Literal["ready", "partial", "not_ready", "insufficient_data"]
11
+
12
+
13
+ class BrandInfo(TypedDict, total=False):
14
+ name: str
15
+ slug: str
16
+ logo: str
17
+
18
+
19
+ class RegionalVariant(TypedDict, total=False):
20
+ region_code: str
21
+ model_variant: str
22
+ notes: str
23
+
24
+
25
+ class TacLookupHit(TypedDict, total=False):
26
+ found: Literal[True]
27
+ tac: str
28
+ brand: BrandInfo
29
+ model: str
30
+ marketing_name: Optional[str]
31
+ model_info: Optional[str]
32
+ device_type: Optional[str]
33
+ iot_rat_support: List[str]
34
+ regional_variant: RegionalVariant
35
+ year: Optional[int]
36
+ chipset: Optional[str]
37
+ image_url: str
38
+ specifications: Dict[str, Any]
39
+ specifications_locked: List[str]
40
+ meta: Dict[str, Any]
41
+
42
+
43
+ class TacLookupMiss(TypedDict):
44
+ found: Literal[False]
45
+ tac: str
46
+ valid_tac: bool
47
+ reason: NotFoundReason
48
+ message: str
@@ -0,0 +1,95 @@
1
+ Metadata-Version: 2.4
2
+ Name: hicelltek-tac
3
+ Version: 1.0.0
4
+ Summary: Official zero-dependency Python client for the HiCellTek IMEI & TAC Intelligence REST API (GSMA TS.06 RBI validation, 4G/5G bands, CA combos, eSIM, VoLTE & 2G/3G sunset readiness).
5
+ Author-email: TAKWA SEBAI <takwa.sebai@hicelltek.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://hicelltek.com/en/imei-api/
8
+ Project-URL: Documentation, https://hicelltek.com/en/api-documentation/
9
+ Project-URL: OpenAPI Schema, https://imei.hicelltek.com/api/v1/openapi.json
10
+ Project-URL: Terms of Service, https://hicelltek.com/en/api-terms/
11
+ Project-URL: Repository, https://github.com/tsebai/hicelltek-tac-python
12
+ Keywords: imei,tac,gsma,3gpp,5g,lte,esim,volte,mvno,telecom,iot
13
+ Classifier: Development Status :: 5 - Production/Stable
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: Intended Audience :: Telecommunications Industry
16
+ Classifier: License :: OSI Approved :: MIT License
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.9
19
+ Classifier: Programming Language :: Python :: 3.10
20
+ Classifier: Programming Language :: Python :: 3.11
21
+ Classifier: Programming Language :: Python :: 3.12
22
+ Classifier: Programming Language :: Python :: 3.13
23
+ Classifier: Topic :: Communications :: Telephony
24
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
25
+ Classifier: Typing :: Typed
26
+ Requires-Python: >=3.9
27
+ Description-Content-Type: text/markdown
28
+ License-File: LICENSE
29
+ Dynamic: license-file
30
+
31
+ # hicelltek-tac · Python Client for the HiCellTek IMEI & TAC Intelligence API
32
+
33
+ [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.24796697.svg)](https://doi.org/10.5281/zenodo.24796697)
34
+
35
+
36
+ Zero-dependency, typed Python client for the **[HiCellTek IMEI & TAC Intelligence REST API](https://hicelltek.com/en/imei-api/)** (`https://imei.hicelltek.com/api`).
37
+
38
+ Built for **MVNOs, Travel eSIM platforms, Mobile Network Operators, M2M/IoT fleet operators, MDM tools, and B2B device marketplaces**.
39
+
40
+ ## Key Capabilities
41
+
42
+ - **Local GSMA / 3GPP Input Validation (Zero Network Call):** Validates 8-digit TACs and verifies 15-digit IMEI Luhn check digits (`3GPP TS 23.003`) locally before sending HTTP requests.
43
+ - **Single & Batch TAC Lookup (`/v1/tac/lookup`, `/v1/tac/batch`):** Resolves brand, model, chipset, device type (`smartphone`, `iot_module`, `pos_terminal`, `automotive_tcu`, `cpe_router`), 4G LTE / 5G NR bands, Carrier Aggregation combinations, and GSMA TS.06 RBI reason codes (`not_in_database`, `test_me_rbi`, `unallocated_rbi`).
44
+ - **Travel eSIM, VoLTE & 2G/3G Sunset Readiness (`/v1/readiness/{imei}/{country}`):** Evaluates eSIM capability, TAC-level regional hardware variants (`EU`, `US`, `CN`, `JP`, `KR`), VoLTE provenance (`volte_source`), VoLTE Emergency (112/911/000), VoLTE Roaming (S8HR/LBO), and IoT RAT taxonomy (`LTE-M`, `NB-IoT`, `Cat-1bis`, `5G RedCap`, `IoT-NTN`) across **164 countries and 582 operators**.
45
+ - **Zero External Dependencies:** Uses only the Python 3.9+ standard library (`urllib.request`, `json`). Runs cleanly in AWS Lambda, Scaleway Functions, Docker slim images, and air-gapped CI pipelines.
46
+
47
+ ## Installation
48
+
49
+ ```bash
50
+ pip install hicelltek-tac
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ Request a 14-day B2B evaluation key (work email required) at **https://hicelltek.com/en/imei-api/** and export it as `HICELLTEK_API_KEY`:
56
+
57
+ ```python
58
+ from hicelltek_tac import HiCellTekTacClient, is_valid_imei_luhn, extract_tac
59
+
60
+ # 1. Offline 3GPP TS 23.003 Luhn check & TAC extraction (zero quota used)
61
+ assert is_valid_imei_luhn("354071151234568") is False
62
+ tac = extract_tac("35407115") # -> "35407115"
63
+
64
+ # 2. Live API lookup (reads HICELLTEK_API_KEY from environment by default)
65
+ client = HiCellTekTacClient()
66
+
67
+ device = client.lookup("35407115")
68
+ if device["found"]:
69
+ print(device["brand"]["name"], device["model"], device.get("chipset"))
70
+
71
+ # 3. Travel eSIM & 2G/3G Sunset Readiness in France (Pro / Business tier)
72
+ readiness = client.check_readiness("35407115", country="FR")
73
+ print(readiness["readiness"]["overall_status"], readiness["readiness"]["warnings"])
74
+ ```
75
+
76
+ ## Error Handling & Anti-Retry Discipline
77
+
78
+ When a TAC is not found (`HTTP 404`), the client returns the structured `TacNotFoundResponse` dictionary (`found: False`, `valid_tac`, `reason`) instead of raising an exception, so your application can inspect `reason`:
79
+
80
+ - `unallocated_rbi`: Reporting Body Identifier never allocated by the GSMA. **Never retry.**
81
+ - `test_me_rbi`: 3GPP Test ME prefix (`00` or `02` to `09`) reserved for conformance/lab equipment.
82
+ - `not_in_database`: Valid GSMA RBI prefix currently absent from the catalogue.
83
+
84
+ Authentication (`401`), plan entitlement (`403`), validation (`422`), and rate-limit (`429`) errors raise `HiCellTekApiError` with `.status_code` and `.payload`.
85
+
86
+ ## Related Telecom Tools by HiCellTek
87
+
88
+ - **IMEI & TAC API Documentation & Pricing:** https://hicelltek.com/en/imei-api/
89
+ - **Free Web TAC Lookup:** https://hicelltek.com/en/tac-lookup/
90
+ - **Free Online 3GPP RRC & NAS Decoder (2G to 5G Rel-19):** https://hicelltek.com/en/decoder/
91
+ - **Android 2G/3G/4G/5G Layer 3 Drive Test & Post-Processing Suite:** https://hicelltek.com/en/drive-test-tool-android/
92
+
93
+ ## Acceptable Use & Legal Notice
94
+
95
+ This client code is licensed under MIT, while all API responses and catalogue records remain strictly governed by the **[HiCellTek API Terms of Service](https://hicelltek.com/en/api-terms/)** (B2B internal operational use only; TAC enumeration, scraping, public checker exposure, and redistribution are strictly prohibited; TAC lookup is not a stolen-device or carrier blacklist registry).
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/hicelltek_tac/__init__.py
5
+ src/hicelltek_tac/client.py
6
+ src/hicelltek_tac/py.typed
7
+ src/hicelltek_tac/types.py
8
+ src/hicelltek_tac.egg-info/PKG-INFO
9
+ src/hicelltek_tac.egg-info/SOURCES.txt
10
+ src/hicelltek_tac.egg-info/dependency_links.txt
11
+ src/hicelltek_tac.egg-info/top_level.txt
12
+ tests/test_client.py
@@ -0,0 +1 @@
1
+ hicelltek_tac
@@ -0,0 +1,156 @@
1
+ """Unit test suite for hicelltek_tac (offline validators + mocked HTTP transport)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import email.message
6
+ import io
7
+ import json
8
+ import sys
9
+ import unittest
10
+ import urllib.error
11
+ from pathlib import Path
12
+ from unittest.mock import patch
13
+
14
+ sys.path.insert(0, str(Path(__file__).resolve().parents[1] / "src"))
15
+
16
+ from hicelltek_tac import ( # noqa: E402
17
+ HiCellTekApiError,
18
+ HiCellTekTacClient,
19
+ classify_tac_prefix,
20
+ compute_luhn_check_digit,
21
+ extract_tac,
22
+ is_valid_imei_luhn,
23
+ )
24
+
25
+
26
+ class _FakeHttpResponse:
27
+ def __init__(self, payload: dict) -> None:
28
+ self._raw = json.dumps(payload).encode("utf-8")
29
+
30
+ def read(self) -> bytes:
31
+ return self._raw
32
+
33
+ def __enter__(self) -> _FakeHttpResponse:
34
+ return self
35
+
36
+ def __exit__(self, *args: object) -> bool:
37
+ return False
38
+
39
+
40
+ class TestOfflineValidators(unittest.TestCase):
41
+ def test_3gpp_ts_23003_luhn_check_digit(self) -> None:
42
+ # 3GPP TS 23.003 standard Luhn verification
43
+ body14 = "35407115123456"
44
+ digit = compute_luhn_check_digit(body14)
45
+ valid_imei = f"{body14}{digit}"
46
+ self.assertTrue(is_valid_imei_luhn(valid_imei))
47
+ self.assertTrue(is_valid_imei_luhn(f"{body14[:8]}-{body14[8:14]}-{digit}"))
48
+ tampered = f"{body14}{(int(digit) + 1) % 10}"
49
+ self.assertFalse(is_valid_imei_luhn(tampered))
50
+ self.assertFalse(is_valid_imei_luhn("35407115"))
51
+
52
+ def test_extract_tac_and_strict_luhn_mode(self) -> None:
53
+ self.assertEqual(extract_tac("3540 7115"), "35407115")
54
+ digit = compute_luhn_check_digit("35407115999999")
55
+ self.assertEqual(extract_tac(f"35407115999999{digit}", strict_luhn=True), "35407115")
56
+ with self.assertRaises(ValueError):
57
+ extract_tac(f"35407115999999{(int(digit) + 2) % 10}", strict_luhn=True)
58
+
59
+ def test_gsma_ts06_test_me_rbi_classification(self) -> None:
60
+ self.assertEqual(classify_tac_prefix("00440015"), "test_me_rbi")
61
+ self.assertEqual(classify_tac_prefix("02123456"), "test_me_rbi")
62
+ self.assertEqual(classify_tac_prefix("01123456"), "commercial_candidate") # PTCRB = 01 (commercial)
63
+ self.assertEqual(classify_tac_prefix("35407115"), "commercial_candidate") # BABT = 35 (commercial)
64
+
65
+
66
+ class TestHiCellTekTacClient(unittest.TestCase):
67
+ def test_security_enforces_https_and_non_empty_key(self) -> None:
68
+ with patch.dict("os.environ", {}, clear=True):
69
+ with self.assertRaises(ValueError):
70
+ HiCellTekTacClient()
71
+ with self.assertRaises(ValueError):
72
+ HiCellTekTacClient(api_key="hct_placeholder", base_url="http://imei.hicelltek.com/api")
73
+ with self.assertRaises(ValueError):
74
+ HiCellTekTacClient(api_key="hct_placeholder", timeout_seconds=0)
75
+
76
+ def test_context_manager_and_privacy_tac_truncation(self) -> None:
77
+ captured: dict = {}
78
+
79
+ def fake_urlopen(req: object, timeout: float = 10.0) -> _FakeHttpResponse:
80
+ r = req # type: ignore[assignment]
81
+ captured["url"] = r.full_url # type: ignore[attr-defined]
82
+ captured["body"] = json.loads(r.data.decode("utf-8")) # type: ignore[attr-defined]
83
+ captured["key"] = r.headers.get("X-api-key") # type: ignore[attr-defined]
84
+ captured["timeout"] = timeout
85
+ return _FakeHttpResponse({"found": True, "tac": "35407115", "model": "Galaxy S24"})
86
+
87
+ with patch("urllib.request.urlopen", side_effect=fake_urlopen):
88
+ with HiCellTekTacClient(api_key="hct_placeholder", timeout_seconds=5.0) as client:
89
+ result = client.lookup("354071150000000")
90
+
91
+ self.assertTrue(result["found"])
92
+ self.assertEqual(captured["url"], "https://imei.hicelltek.com/api/v1/tac/lookup")
93
+ self.assertEqual(captured["body"], {"query": "35407115", "lang": "en"})
94
+ self.assertEqual(captured["key"], "hct_placeholder")
95
+ self.assertEqual(captured["timeout"], 5.0)
96
+
97
+ def test_404_structured_rbi_reason_returned_without_exception(self) -> None:
98
+ client = HiCellTekTacClient(api_key="hct_placeholder")
99
+ miss_payload = {
100
+ "found": False,
101
+ "tac": "99123456",
102
+ "valid_tac": False,
103
+ "reason": "unallocated_rbi",
104
+ "message": "Unallocated RBI",
105
+ }
106
+ err = urllib.error.HTTPError(
107
+ url="https://imei.hicelltek.com/api/v1/tac/lookup",
108
+ code=404,
109
+ msg="Not Found",
110
+ hdrs=email.message.Message(),
111
+ fp=io.BytesIO(json.dumps(miss_payload).encode("utf-8")),
112
+ )
113
+ with patch("urllib.request.urlopen", side_effect=err):
114
+ result = client.lookup("99123456")
115
+ self.assertFalse(result["found"])
116
+ self.assertEqual(result["reason"], "unallocated_rbi")
117
+
118
+ def test_429_parses_retry_after_header(self) -> None:
119
+ client = HiCellTekTacClient(api_key="hct_placeholder")
120
+ hdrs = email.message.Message()
121
+ hdrs["Retry-After"] = "45"
122
+ err = urllib.error.HTTPError(
123
+ url="https://imei.hicelltek.com/api/v1/tac/lookup",
124
+ code=429,
125
+ msg="Too Many Requests",
126
+ hdrs=hdrs,
127
+ fp=io.BytesIO(json.dumps({"message": "Daily quota reached"}).encode("utf-8")),
128
+ )
129
+ with patch("urllib.request.urlopen", side_effect=err):
130
+ with self.assertRaises(HiCellTekApiError) as ctx:
131
+ client.lookup("35407115")
132
+ self.assertEqual(ctx.exception.status_code, 429)
133
+ self.assertEqual(ctx.exception.retry_after_seconds, 45)
134
+ self.assertIn("Daily quota reached", ctx.exception.message)
135
+
136
+ def test_batch_rejects_strings_empty_and_over_100(self) -> None:
137
+ client = HiCellTekTacClient(api_key="hct_placeholder")
138
+ with self.assertRaises(ValueError):
139
+ client.batch_lookup([])
140
+ with self.assertRaises(ValueError):
141
+ client.batch_lookup("35407115") # passing a bare string instead of list must fail loudly
142
+ with self.assertRaises(ValueError):
143
+ client.batch_lookup(["35407115"] * 101)
144
+
145
+ def test_readiness_and_usage_input_validation(self) -> None:
146
+ client = HiCellTekTacClient(api_key="hct_placeholder")
147
+ with self.assertRaises(ValueError):
148
+ client.check_readiness("35407115", "FRA")
149
+ with self.assertRaises(ValueError):
150
+ client.key_usage(days=0)
151
+ with self.assertRaises(ValueError):
152
+ client.key_usage(days=True) # bool is a subclass of int in Python
153
+
154
+
155
+ if __name__ == "__main__":
156
+ unittest.main()