class PriorityAliases(enum.Enum): low = 1000 medium = 2000 high = 3000 class StrictMergeParameter(enum.Enum): true = True false = False fasttrack = "smart+fasttrack" ordered = "smart+ordered" mergify_json.register_type(StrictMergeParameter) def Priority(v): try: return PriorityAliases[v].value except KeyError: return v MAX_PRIORITY: int = 10000 # NOTE(sileht): We use the max priority as an offset to order queue QUEUE_PRIORITY_OFFSET: int = MAX_PRIORITY PrioritySchema = voluptuous.All(
with_enum_encode = { "name": "hello", "conditions": [], "actions": { "merge": { "strict": { "__pytype__": "enum", "class": "Color", "name": "BLUE" } } }, } mergify_json.register_type(Color) def test_register_type_fail(): with pytest.raises(RuntimeError): mergify_json.register_type(Color) def test_encode_enum(): assert json.loads(mergify_json.dumps(with_enum)) == with_enum_encode def test_decode_enum(): json_file = mergify_json.dumps(with_enum) assert mergify_json.loads(json_file) == with_enum
def test_register_type_fail(): with pytest.raises(RuntimeError): mergify_json.register_type(Color)
elif self.value == "action_required": return "⚠️" return None def __str__(self) -> str: prefix = self.emoji if prefix is None: prefix = "" else: prefix = prefix + " " return prefix + self._normalize(self.name) json.register_type(Conclusion) @dataclasses.dataclass class Result: conclusion: Conclusion title: str summary: str annotations: typing.Optional[typing.List[ github_types.GitHubAnnotation]] = None started_at: typing.Optional[datetime.datetime] = None ended_at: typing.Optional[datetime.datetime] = None def to_check_run_light( check: github_types.GitHubCheckRun, ) -> github_types.CachedGitHubCheckRun: