Coverage for functions \ flipdare \ job \ job_config_option.py: 95%

40 statements  

« prev     ^ index     » next       coverage.py v7.13.0, created at 2026-05-08 12:22 +1000

1#!/usr/bin/env python 

2# Copyright (c) 2026 Flipdare Pty Ltd. All rights reserved. 

3# 

4# This file is part of Flipdare's proprietary software and contains 

5# confidential and copyrighted material. Unauthorised copying, 

6# modification, distribution, or use of this file is strictly 

7# prohibited without prior written permission from Flipdare Pty Ltd. 

8# 

9# This software includes third-party components licensed under MIT, 

10# BSD, and Apache 2.0 licences. See THIRD_PARTY_NOTICES for details. 

11# 

12 

13 

14from dataclasses import dataclass, field 

15 

16from flipdare.generated.shared.backend.app_job_group import AppJobGroup 

17from flipdare.generated.shared.backend.app_job_type import AppJobType 

18from flipdare.job.app_job_schedule import AppJobSchedule 

19 

20 

21@dataclass(frozen=True, slots=True) 

22class JobConfigOption: # type: ignore[misc] 

23 name: str 

24 _schedule: AppJobSchedule | None = field(default=None, repr=False, compare=False) 

25 _job_type: AppJobType | None = field(default=None, repr=False, compare=False) 

26 

27 @property 

28 def job_type_str(self) -> str: 

29 """Get the full job type name (e.g., 'user_created', 'voting')""" 

30 return self.name 

31 

32 @property 

33 def job_type(self) -> AppJobType: 

34 """Get the AppJobType enum for this job (raises if not found)""" 

35 if self._job_type is None: 

36 raise ValueError(f"Job {self.name} does not have a valid AppJobType mapping") 

37 return self._job_type 

38 

39 @property 

40 def job_group(self) -> AppJobGroup: 

41 """Get the AppJobGroup enum for this job (raises if not found)""" 

42 return self.job_type.job_group 

43 

44 @property 

45 def description(self) -> str: 

46 """Get the description for this job (raises if not found)""" 

47 return self.job_type.description 

48 

49 @property 

50 def is_task(self) -> bool: 

51 """Check if this is a scheduled task (not a trigger)""" 

52 return self.job_type.is_task 

53 

54 @property 

55 def is_command(self) -> bool: 

56 """Check if this is a command""" 

57 return self.job_type.is_command 

58 

59 @property 

60 def is_report(self) -> bool: 

61 """Check if this is a report""" 

62 return self.job_type.is_report 

63 

64 @property 

65 def is_trigger(self) -> bool: 

66 """Check if this is a trigger (not a scheduled task)""" 

67 return self.job_type.is_trigger 

68 

69 @property 

70 def schedule(self) -> AppJobSchedule: 

71 """Get the schedule enum for this job""" 

72 if self._schedule is None: 

73 raise ValueError(f"Job {self.name} does not have a valid AppJobSchedule mapping") 

74 return self._schedule