orgdatacore 2.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.
- orgdatacore-2.0.0/.gitignore +33 -0
- orgdatacore-2.0.0/CHANGELOG.md +65 -0
- orgdatacore-2.0.0/CLAUDE.md +313 -0
- orgdatacore-2.0.0/LICENSE +201 -0
- orgdatacore-2.0.0/PKG-INFO +444 -0
- orgdatacore-2.0.0/README.md +409 -0
- orgdatacore-2.0.0/RELEASING.md +79 -0
- orgdatacore-2.0.0/examples/__init__.py +1 -0
- orgdatacore-2.0.0/examples/async_demo.py +142 -0
- orgdatacore-2.0.0/examples/async_performance_demo.py +256 -0
- orgdatacore-2.0.0/examples/gcs_demo.py +127 -0
- orgdatacore-2.0.0/orgdatacore/__init__.py +156 -0
- orgdatacore-2.0.0/orgdatacore/_anonymization.py +465 -0
- orgdatacore-2.0.0/orgdatacore/_async.py +1516 -0
- orgdatacore-2.0.0/orgdatacore/_exceptions.py +82 -0
- orgdatacore-2.0.0/orgdatacore/_gcs.py +317 -0
- orgdatacore-2.0.0/orgdatacore/_internal/__init__.py +5 -0
- orgdatacore-2.0.0/orgdatacore/_internal/testing/__init__.py +16 -0
- orgdatacore-2.0.0/orgdatacore/_internal/testing/fake_gcs.py +173 -0
- orgdatacore-2.0.0/orgdatacore/_internal/testing/filesource.py +147 -0
- orgdatacore-2.0.0/orgdatacore/_internal/testing/helpers.py +192 -0
- orgdatacore-2.0.0/orgdatacore/_log.py +98 -0
- orgdatacore-2.0.0/orgdatacore/_redaction.py +215 -0
- orgdatacore-2.0.0/orgdatacore/_serialization.py +24 -0
- orgdatacore-2.0.0/orgdatacore/_service.py +1458 -0
- orgdatacore-2.0.0/orgdatacore/_types.py +269 -0
- orgdatacore-2.0.0/orgdatacore/_version.py +119 -0
- orgdatacore-2.0.0/orgdatacore/py.typed +0 -0
- orgdatacore-2.0.0/pyproject.toml +124 -0
- orgdatacore-2.0.0/requirements-dev.txt +16 -0
- orgdatacore-2.0.0/requirements.txt +6 -0
- orgdatacore-2.0.0/tests/__init__.py +1 -0
- orgdatacore-2.0.0/tests/conftest.py +32 -0
- orgdatacore-2.0.0/tests/test_anonymization.py +700 -0
- orgdatacore-2.0.0/tests/test_async_service.py +683 -0
- orgdatacore-2.0.0/tests/test_context.py +140 -0
- orgdatacore-2.0.0/tests/test_edge_cases.py +345 -0
- orgdatacore-2.0.0/tests/test_employee.py +240 -0
- orgdatacore-2.0.0/tests/test_exceptions.py +70 -0
- orgdatacore-2.0.0/tests/test_gcs.py +337 -0
- orgdatacore-2.0.0/tests/test_hierarchy.py +240 -0
- orgdatacore-2.0.0/tests/test_hierarchy_api.py +159 -0
- orgdatacore-2.0.0/tests/test_logging.py +51 -0
- orgdatacore-2.0.0/tests/test_mapping.py +241 -0
- orgdatacore-2.0.0/tests/test_organization.py +178 -0
- orgdatacore-2.0.0/tests/test_pillar.py +99 -0
- orgdatacore-2.0.0/tests/test_redaction.py +374 -0
- orgdatacore-2.0.0/tests/test_service.py +266 -0
- orgdatacore-2.0.0/tests/test_stable_id.py +354 -0
- orgdatacore-2.0.0/tests/test_team.py +389 -0
- orgdatacore-2.0.0/tests/test_team_group.py +99 -0
- orgdatacore-2.0.0/tests/test_version.py +100 -0
- orgdatacore-2.0.0/uv.lock +903 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Byte-compiled / optimized / DLL files
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
|
|
6
|
+
# Distribution / packaging
|
|
7
|
+
*.egg-info/
|
|
8
|
+
*.egg
|
|
9
|
+
dist/
|
|
10
|
+
build/
|
|
11
|
+
|
|
12
|
+
# Virtual environments
|
|
13
|
+
venv/
|
|
14
|
+
.venv/
|
|
15
|
+
env/
|
|
16
|
+
|
|
17
|
+
# IDE
|
|
18
|
+
.idea/
|
|
19
|
+
.vscode/
|
|
20
|
+
*.swp
|
|
21
|
+
|
|
22
|
+
# Testing
|
|
23
|
+
.pytest_cache/
|
|
24
|
+
.coverage
|
|
25
|
+
htmlcov/
|
|
26
|
+
.tox/
|
|
27
|
+
|
|
28
|
+
# mypy
|
|
29
|
+
.mypy_cache/
|
|
30
|
+
|
|
31
|
+
# UV (virtual environment is in .venv, already ignored above)
|
|
32
|
+
# Note: uv.lock should be committed for reproducible builds
|
|
33
|
+
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to the `orgdatacore` Python package are documented here.
|
|
4
|
+
|
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
+
|
|
8
|
+
## [Unreleased]
|
|
9
|
+
|
|
10
|
+
Nothing yet.
|
|
11
|
+
|
|
12
|
+
## [2.0.0] — unreleased
|
|
13
|
+
|
|
14
|
+
Adopt the canonical [`orgindex-schema`](https://github.com/openshift-eng/orgindex-schema)
|
|
15
|
+
models as the single source of truth for the on-disk index shape (OCPCRT-658).
|
|
16
|
+
This is a breaking change to the **model shape**; the query-method API and load
|
|
17
|
+
behavior are unchanged (verified against a real production index — cross-branch
|
|
18
|
+
differential test: 36,348 cases, 0 mismatches).
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
- `orgindex-schema` is now a **required** dependency
|
|
22
|
+
(`orgindex-schema>=0.1.0,<0.2.0`, published on PyPI). It is pulled in
|
|
23
|
+
automatically by pip/uv when installing `orgdatacore`; no manual install is
|
|
24
|
+
needed. The upper bound caps at the next minor because the schema is pre-1.0
|
|
25
|
+
(a `0.2.0` may be breaking under SemVer).
|
|
26
|
+
- `Employee.possible_github_ids` field (from the canonical schema).
|
|
27
|
+
- `cohorts` lookup collection on `Lookups`.
|
|
28
|
+
- PII redaction/anonymization now scrub `possible_github_ids` and also cover the
|
|
29
|
+
`cohorts` collection.
|
|
30
|
+
|
|
31
|
+
### Changed
|
|
32
|
+
- On-disk index/entity models are re-exported from `orgindex-schema` under their
|
|
33
|
+
historical names. `Team`/`Org`/`Pillar`/`TeamGroup` are now the single
|
|
34
|
+
`HierarchyEntity`; `Component` is `ComponentEntry` with its detail nested under
|
|
35
|
+
`.component`; `Data` is `ComprehensiveIndexModel`.
|
|
36
|
+
- Model collection fields are now `list` (previously `tuple`). Frozen models that
|
|
37
|
+
hold populated list fields are therefore no longer hashable.
|
|
38
|
+
- `RepoInfo.repo` is now `repo_name`; the group role list is `resolved_roles`
|
|
39
|
+
(previously `roles`).
|
|
40
|
+
- Serialization goes through `model_dump`, so cleared/empty optional fields are
|
|
41
|
+
emitted as `""` / `[]` rather than omitted from the JSON.
|
|
42
|
+
|
|
43
|
+
### Removed
|
|
44
|
+
- `Employee.rhat_geo`, `Employee.cost_center`, `Employee.is_people_manager`
|
|
45
|
+
(not present in real producer output).
|
|
46
|
+
- Top-level `uid`, `tab_name`, and `type` on hierarchy entities
|
|
47
|
+
(`Team`/`Org`/`Pillar`/`TeamGroup`); identity is carried by `stable_id` /
|
|
48
|
+
`parent_id`.
|
|
49
|
+
- `Metadata.total_teams`.
|
|
50
|
+
- The `JiraIndex` and `ComponentOwnershipIndex` exports (these indexes are bare
|
|
51
|
+
maps, matching the Go `map` types).
|
|
52
|
+
|
|
53
|
+
### Migration notes
|
|
54
|
+
- Code that only **calls `Service` query methods** needs no changes.
|
|
55
|
+
- Code that reads the removed/renamed fields, imports `JiraIndex` /
|
|
56
|
+
`ComponentOwnershipIndex`, relies on `tuple`-typed collections, or hashes model
|
|
57
|
+
instances must be updated.
|
|
58
|
+
|
|
59
|
+
## [1.0.0]
|
|
60
|
+
|
|
61
|
+
Initial tracked release (pre-canonical models). Hand-maintained pydantic models
|
|
62
|
+
describing the on-disk index, consumed by `Service`.
|
|
63
|
+
|
|
64
|
+
[Unreleased]: https://github.com/openshift-eng/cyborg-data/compare/python-v2.0.0...HEAD
|
|
65
|
+
[2.0.0]: https://github.com/openshift-eng/cyborg-data/releases/tag/python-v2.0.0
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# Python Implementation Guide
|
|
2
|
+
|
|
3
|
+
## Quick Reference
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
cd python
|
|
7
|
+
pytest # Run all tests
|
|
8
|
+
pytest tests/test_employee.py # Run specific tests
|
|
9
|
+
ruff check . && ruff format . # Lint and format
|
|
10
|
+
mypy orgdatacore # Type check
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Extending the API
|
|
14
|
+
|
|
15
|
+
### Adding a New Query Method
|
|
16
|
+
|
|
17
|
+
Follow this exact pattern for every new method:
|
|
18
|
+
|
|
19
|
+
#### Step 1: Implement in Service (`_service.py`)
|
|
20
|
+
|
|
21
|
+
```python
|
|
22
|
+
def get_new_thing_by_param(self, param: str) -> NewThing | None:
|
|
23
|
+
"""Get a NewThing by param.
|
|
24
|
+
|
|
25
|
+
Args:
|
|
26
|
+
param: The parameter to look up.
|
|
27
|
+
|
|
28
|
+
Returns:
|
|
29
|
+
The NewThing if found, None otherwise.
|
|
30
|
+
"""
|
|
31
|
+
with self._lock:
|
|
32
|
+
# ALWAYS check for None data first
|
|
33
|
+
if self._data is None or not self._data.lookups.some_map:
|
|
34
|
+
return None
|
|
35
|
+
|
|
36
|
+
# Use O(1) lookup - NEVER traverse
|
|
37
|
+
return self._data.lookups.some_map.get(param)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
#### Step 2: Add Tests (`tests/test_*.py`)
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
class TestGetNewThingByParam:
|
|
44
|
+
"""Tests for new thing lookup by param."""
|
|
45
|
+
|
|
46
|
+
@pytest.mark.parametrize("param,expected", [
|
|
47
|
+
("valid", NewThing(uid="valid", name="Valid Thing")),
|
|
48
|
+
("nonexistent", None),
|
|
49
|
+
("", None),
|
|
50
|
+
])
|
|
51
|
+
def test_get_new_thing_by_param(
|
|
52
|
+
self, service: Service, param: str, expected: NewThing | None
|
|
53
|
+
):
|
|
54
|
+
"""Test new thing lookup by param."""
|
|
55
|
+
result = service.get_new_thing_by_param(param)
|
|
56
|
+
assert result == expected
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### Design Rules
|
|
60
|
+
|
|
61
|
+
1. **Thread Safety**: Always use `with self._lock:` for data access
|
|
62
|
+
2. **None Checks**: Check `self._data` and the specific collection before accessing
|
|
63
|
+
3. **Return Optional**: Return `Type | None` for single entities
|
|
64
|
+
4. **Return Lists**: Return `list[Type]` for collections (empty list, not None)
|
|
65
|
+
5. **Type Hints**: All parameters and returns must be typed
|
|
66
|
+
|
|
67
|
+
### Performance Guidelines
|
|
68
|
+
|
|
69
|
+
**Hot path methods** (called frequently, latency-sensitive):
|
|
70
|
+
- MUST use pre-computed indexes for O(1) lookup
|
|
71
|
+
- Examples: `get_employee_by_slack_id`, `is_employee_in_team`, `get_teams_for_uid`
|
|
72
|
+
|
|
73
|
+
**Cold path methods** (infrequent, admin/debug use):
|
|
74
|
+
- MAY traverse data if index cost outweighs benefit
|
|
75
|
+
- Document the O(n) complexity in docstring
|
|
76
|
+
- Examples: `get_employee_by_email`, `get_all_employee_uids`
|
|
77
|
+
|
|
78
|
+
When adding a new method, consider:
|
|
79
|
+
- How often will this be called?
|
|
80
|
+
- Is there an existing index that covers this case?
|
|
81
|
+
- Would a new index significantly grow the data file?
|
|
82
|
+
|
|
83
|
+
If traversal is acceptable, document it:
|
|
84
|
+
```python
|
|
85
|
+
def get_employee_by_email(self, email: str) -> Employee | None:
|
|
86
|
+
"""Get an employee by email address.
|
|
87
|
+
|
|
88
|
+
Note: O(n) scan - use get_employee_by_uid for hot paths.
|
|
89
|
+
"""
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Method Categories
|
|
93
|
+
|
|
94
|
+
| Category | Return Type | None Check Pattern |
|
|
95
|
+
|----------|-------------|-------------------|
|
|
96
|
+
| Single entity lookup | `Employee \| None` | Return `None` if not found |
|
|
97
|
+
| Collection lookup | `list[str]` | Return empty list `[]` |
|
|
98
|
+
| Boolean check | `bool` | Return `False` if data unavailable |
|
|
99
|
+
| Version/metadata | `DataVersion` | Return default instance |
|
|
100
|
+
|
|
101
|
+
### Lookup Patterns
|
|
102
|
+
|
|
103
|
+
**Direct dict lookup** (e.g., get_employee_by_uid):
|
|
104
|
+
```python
|
|
105
|
+
def get_employee_by_uid(self, uid: str) -> Employee | None:
|
|
106
|
+
with self._lock:
|
|
107
|
+
if self._data is None or not self._data.lookups.employees:
|
|
108
|
+
return None
|
|
109
|
+
return self._data.lookups.employees.get(uid)
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
**Two-step lookup** (e.g., get_employee_by_slack_id):
|
|
113
|
+
```python
|
|
114
|
+
def get_employee_by_slack_id(self, slack_id: str) -> Employee | None:
|
|
115
|
+
with self._lock:
|
|
116
|
+
if (
|
|
117
|
+
self._data is None
|
|
118
|
+
or not self._data.indexes.slack_id_mappings.slack_uid_to_uid
|
|
119
|
+
or not self._data.lookups.employees
|
|
120
|
+
):
|
|
121
|
+
return None
|
|
122
|
+
|
|
123
|
+
uid = self._data.indexes.slack_id_mappings.slack_uid_to_uid.get(slack_id, "")
|
|
124
|
+
if not uid:
|
|
125
|
+
return None
|
|
126
|
+
|
|
127
|
+
return self._data.lookups.employees.get(uid)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
**Membership iteration** (e.g., get_teams_for_uid):
|
|
131
|
+
```python
|
|
132
|
+
def get_teams_for_uid(self, uid: str) -> list[str]:
|
|
133
|
+
with self._lock:
|
|
134
|
+
if self._data is None or not self._data.indexes.membership.membership_index:
|
|
135
|
+
return []
|
|
136
|
+
|
|
137
|
+
memberships = self._data.indexes.membership.membership_index.get(uid, ())
|
|
138
|
+
return [m.name for m in memberships if m.type == MembershipType.TEAM]
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## File Organization
|
|
142
|
+
|
|
143
|
+
| File | Purpose |
|
|
144
|
+
|------|---------|
|
|
145
|
+
| `_service.py` | `Service` class implementation |
|
|
146
|
+
| `_types.py` | Data structures (Employee, Team, etc.) |
|
|
147
|
+
| `_exceptions.py` | Custom exceptions |
|
|
148
|
+
| `_log.py` | Logging utilities |
|
|
149
|
+
| `_gcs.py` | GCS data source (optional) |
|
|
150
|
+
| `__init__.py` | Public API exports |
|
|
151
|
+
|
|
152
|
+
### Test File Mapping
|
|
153
|
+
|
|
154
|
+
| Entity | Test File |
|
|
155
|
+
|--------|-----------|
|
|
156
|
+
| Employee queries | `tests/test_employee.py` |
|
|
157
|
+
| Team queries | `tests/test_team.py` |
|
|
158
|
+
| Org queries | `tests/test_organization.py` |
|
|
159
|
+
| Pillar queries | `tests/test_pillar.py` |
|
|
160
|
+
| TeamGroup queries | `tests/test_team_group.py` |
|
|
161
|
+
| Service lifecycle | `tests/test_service.py` |
|
|
162
|
+
| Edge cases | `tests/test_edge_cases.py` |
|
|
163
|
+
|
|
164
|
+
## Adding a New Entity Type
|
|
165
|
+
|
|
166
|
+
1. Add model to `_types.py`:
|
|
167
|
+
```python
|
|
168
|
+
class NewEntity(BaseModel):
|
|
169
|
+
"""Represents a new entity in the organizational data."""
|
|
170
|
+
|
|
171
|
+
model_config = ConfigDict(frozen=True)
|
|
172
|
+
|
|
173
|
+
uid: str = ""
|
|
174
|
+
name: str = ""
|
|
175
|
+
# ... fields match JSON structure
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
2. Add to `Lookups` model:
|
|
179
|
+
```python
|
|
180
|
+
class Lookups(BaseModel):
|
|
181
|
+
# ... existing fields ...
|
|
182
|
+
new_entities: dict[str, NewEntity] = Field(default_factory=dict)
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
3. Add parser function in `_service.py`:
|
|
186
|
+
```python
|
|
187
|
+
def _parse_new_entity(data: dict[str, Any]) -> NewEntity:
|
|
188
|
+
"""Parse a NewEntity from a dictionary."""
|
|
189
|
+
return NewEntity(
|
|
190
|
+
uid=data.get("uid", ""),
|
|
191
|
+
name=data.get("name", ""),
|
|
192
|
+
)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
4. Update `_parse_data()` to include the new entity
|
|
196
|
+
|
|
197
|
+
5. Add query method following the pattern above
|
|
198
|
+
|
|
199
|
+
6. Add tests and update `testdata/test_org_data.json`
|
|
200
|
+
|
|
201
|
+
## Adding a New Index Mapping
|
|
202
|
+
|
|
203
|
+
For new external ID → UID mappings:
|
|
204
|
+
|
|
205
|
+
1. Add mapping model to `_types.py`:
|
|
206
|
+
```python
|
|
207
|
+
class NewIDMappings(BaseModel):
|
|
208
|
+
"""Contains New ID to UID mappings."""
|
|
209
|
+
|
|
210
|
+
model_config = ConfigDict(frozen=True)
|
|
211
|
+
|
|
212
|
+
new_id_to_uid: dict[str, str] = Field(default_factory=dict)
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
2. Add to `Indexes` model:
|
|
216
|
+
```python
|
|
217
|
+
class Indexes(BaseModel):
|
|
218
|
+
# ... existing fields ...
|
|
219
|
+
new_id_mappings: NewIDMappings = Field(default_factory=NewIDMappings)
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
3. Update `_parse_data()` to parse the new mappings
|
|
223
|
+
|
|
224
|
+
4. Add lookup method following the two-step pattern
|
|
225
|
+
|
|
226
|
+
## Type Hints
|
|
227
|
+
|
|
228
|
+
All code must pass `mypy --strict`:
|
|
229
|
+
|
|
230
|
+
```python
|
|
231
|
+
# Correct: Union with None for optional returns
|
|
232
|
+
def get_employee_by_uid(self, uid: str) -> Employee | None:
|
|
233
|
+
|
|
234
|
+
# Correct: List for collections
|
|
235
|
+
def get_all_team_names(self) -> list[str]:
|
|
236
|
+
|
|
237
|
+
# Correct: Tuple for immutable sequences in models
|
|
238
|
+
class SlackConfig(BaseModel):
|
|
239
|
+
model_config = ConfigDict(frozen=True)
|
|
240
|
+
channels: tuple[ChannelInfo, ...] = ()
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Pydantic Model Conventions
|
|
244
|
+
|
|
245
|
+
Always use frozen pydantic BaseModel:
|
|
246
|
+
```python
|
|
247
|
+
class Employee(BaseModel):
|
|
248
|
+
model_config = ConfigDict(frozen=True)
|
|
249
|
+
|
|
250
|
+
uid: str = ""
|
|
251
|
+
full_name: str = ""
|
|
252
|
+
# Default values for all fields
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
- `frozen=True`: Immutability for thread safety
|
|
256
|
+
- Only add `populate_by_name=True` if the model has aliased fields (`Field(alias=...)`)
|
|
257
|
+
- Use `Field(default_factory=...)` for mutable defaults (dicts, lists)
|
|
258
|
+
|
|
259
|
+
## Protocol-Based DataSource
|
|
260
|
+
|
|
261
|
+
DataSource uses Protocol (structural typing):
|
|
262
|
+
```python
|
|
263
|
+
class DataSource(Protocol):
|
|
264
|
+
def load(self) -> BinaryIO: ...
|
|
265
|
+
def watch(self, callback: Callable[[], Exception | None]) -> Exception | None: ...
|
|
266
|
+
def __str__(self) -> str: ...
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
No inheritance required - just implement the methods.
|
|
270
|
+
|
|
271
|
+
## Logging
|
|
272
|
+
|
|
273
|
+
Use the standard library logger:
|
|
274
|
+
```python
|
|
275
|
+
from ._log import get_logger
|
|
276
|
+
|
|
277
|
+
logger = get_logger()
|
|
278
|
+
logger.info("action completed", extra={"key": value})
|
|
279
|
+
logger.error("action failed", extra={"error": str(e)})
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Optional Dependencies
|
|
283
|
+
|
|
284
|
+
GCS support via extras:
|
|
285
|
+
```bash
|
|
286
|
+
pip install orgdatacore[gcs]
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
Check availability at runtime:
|
|
290
|
+
```python
|
|
291
|
+
try:
|
|
292
|
+
from google.cloud import storage
|
|
293
|
+
HAS_GCS = True
|
|
294
|
+
except ImportError:
|
|
295
|
+
HAS_GCS = False
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
## Test Fixtures
|
|
299
|
+
|
|
300
|
+
Use pytest fixtures from `conftest.py`:
|
|
301
|
+
```python
|
|
302
|
+
@pytest.fixture
|
|
303
|
+
def service() -> Service:
|
|
304
|
+
"""Create a service with test data loaded."""
|
|
305
|
+
# Uses shared testdata/test_org_data.json
|
|
306
|
+
...
|
|
307
|
+
```
|
|
308
|
+
|
|
309
|
+
## Remember
|
|
310
|
+
|
|
311
|
+
After implementing in Python:
|
|
312
|
+
1. **Implement the same method in Go** (see `go/CLAUDE.md`)
|
|
313
|
+
2. Run `make test` from repository root to verify parity
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 Red Hat, LLC.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|