Coverage for src/debputy/integration_detection.py: 83%

15 statements  

« prev     ^ index     » next       coverage.py v7.6.0, created at 2025-01-27 13:59 +0000

1from typing import Container, Optional, Mapping 

2 

3from debputy.plugin.api.spec import ( 

4 DebputyIntegrationMode, 

5 INTEGRATION_MODE_DH_DEBPUTY_RRR, 

6 INTEGRATION_MODE_DH_DEBPUTY, 

7 INTEGRATION_MODE_FULL, 

8) 

9 

10 

11def determine_debputy_integration_mode( 

12 source_fields: Mapping[str, str], 

13 all_sequences: Container[str], 

14) -> Optional[DebputyIntegrationMode]: 

15 

16 if source_fields.get("Build-Driver", "").lower() == "debputy": 16 ↛ 17line 16 didn't jump to line 17 because the condition on line 16 was never true

17 return INTEGRATION_MODE_FULL 

18 

19 has_zz_debputy = "zz-debputy" in all_sequences or "debputy" in all_sequences 

20 has_zz_debputy_rrr = "zz-debputy-rrr" in all_sequences 

21 has_any_existing = has_zz_debputy or has_zz_debputy_rrr 

22 if has_zz_debputy_rrr: 

23 return INTEGRATION_MODE_DH_DEBPUTY_RRR 

24 if has_any_existing: 

25 return INTEGRATION_MODE_DH_DEBPUTY 

26 if source_fields.get("Source", "") == "debputy": 26 ↛ 28line 26 didn't jump to line 28 because the condition on line 26 was never true

27 # Self-hosting. We cannot set the Build-Driver field since that creates a self-circular dependency loop 

28 return INTEGRATION_MODE_FULL 

29 return None