Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions adaptive_cards_python/adaptive_card/Action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,16 @@
from typing import Annotated, Any, Literal
from pathlib import Path
from pydantic import Field, ConfigDict
from adaptive_cards_python.case_insensitive_literal import CaseInsensitiveLiteral

from .Extendable import Item, ConfiguredBaseModel
from .config import FallbackOption

import orjson


ActionMode = CaseInsensitiveLiteral[Literal["primary", "secondary"]]
ActionMode = Literal["primary", "secondary"]

ActionStyle = CaseInsensitiveLiteral[Literal["default", "positive", "destructive"]]
ActionStyle = Literal["default", "positive", "destructive"]


class ActionBase(Item):
Expand Down Expand Up @@ -74,7 +73,7 @@ class ActionBase(Item):
)


AssociatedInputs = CaseInsensitiveLiteral[Literal["Auto", "None"]]
AssociatedInputs = Literal["Auto", "None"]


def get_json_schema_file() -> Path:
Expand Down
2 changes: 1 addition & 1 deletion adaptive_cards_python/adaptive_card/AdaptiveCard.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations # Required to defer type hint evaluation!

from typing import Any, Self, Literal
from typing import Any, Literal, Self
from pathlib import Path
import json

Expand Down
49 changes: 18 additions & 31 deletions adaptive_cards_python/adaptive_card/config.py
Original file line number Diff line number Diff line change
@@ -1,38 +1,25 @@
from __future__ import annotations # Required to defer type hint evaluation!
from typing import Literal
from adaptive_cards_python.case_insensitive_literal import CaseInsensitiveLiteral

Spacing = CaseInsensitiveLiteral[
Literal["default", "none", "small", "medium", "large", "extraLarge", "padding"]
]
BlockElementHeight = CaseInsensitiveLiteral[Literal["auto", "stretch"]]
FallbackOption = CaseInsensitiveLiteral[Literal["drop"]]
ContainerStyle = CaseInsensitiveLiteral[
Literal["default", "emphasis", "good", "attention", "warning", "accent"]
]
FontSize = CaseInsensitiveLiteral[
Literal["default", "small", "medium", "large", "extraLarge"]
]
FontType = CaseInsensitiveLiteral[Literal["default", "monospace"]]
FontWeight = CaseInsensitiveLiteral[Literal["default", "lighter", "bolder"]]
HorizontalAlignment = CaseInsensitiveLiteral[Literal["left", "center", "right"]]
ImageFillMode = CaseInsensitiveLiteral[
Literal["cover", "repeatHorizontally", "repeatVertically", "repeat"]

Spacing = Literal[
"default", "none", "small", "medium", "large", "extraLarge", "padding"
]
ImageSize = CaseInsensitiveLiteral[
Literal["auto", "stretch", "small", "medium", "large"]
BlockElementHeight = Literal["auto", "stretch"]
FallbackOption = Literal["drop"]
ContainerStyle = Literal[
"default", "emphasis", "good", "attention", "warning", "accent"
]
ImageStyle = CaseInsensitiveLiteral[Literal["default", "person"]]
TextBlockStyle = CaseInsensitiveLiteral[Literal["default", "heading"]]
VerticalAlignment = CaseInsensitiveLiteral[Literal["top", "center", "bottom"]]
VerticalContentAlignment = CaseInsensitiveLiteral[Literal["top", "center", "bottom"]]
FontSize = Literal["default", "small", "medium", "large", "extraLarge"]
FontType = Literal["default", "monospace"]
FontWeight = Literal["default", "lighter", "bolder"]
HorizontalAlignment = Literal["left", "center", "right"]
ImageFillMode = Literal["cover", "repeatHorizontally", "repeatVertically", "repeat"]
ImageSize = Literal["auto", "stretch", "small", "medium", "large"]
ImageStyle = Literal["default", "person"]
TextBlockStyle = Literal["default", "heading"]
VerticalAlignment = Literal["top", "center", "bottom"]
VerticalContentAlignment = Literal["top", "center", "bottom"]
Colors = (
(
CaseInsensitiveLiteral[
Literal[
"default", "dark", "light", "accent", "good", "warning", "attention"
]
]
)
| str
Literal["default", "dark", "light", "accent", "good", "warning", "attention"] | str
)
67 changes: 0 additions & 67 deletions adaptive_cards_python/case_insensitive_literal.py

This file was deleted.

192 changes: 0 additions & 192 deletions tests/test_case_insensitive_literal.py

This file was deleted.

10 changes: 5 additions & 5 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"version": "1.5",
"body": [],
}
WEBHOOK_URL = "<REDACTED_WEBHOOK_URL>"
WEBHOOK_URL = "<MY_MSTEAMS_WORKFLOW_WEBHOOK_URL>"


def test_valid_card():
Expand Down Expand Up @@ -113,14 +113,14 @@ def test_construct_card():
actions_list.append(
actions.OpenUrl(
title="View Contract",
url="https://example.com/contract.yaml",
url="https://github.com/axteams-one/ddm-contracts/blob/main/contracts/idd/acap_list.yaml",
)
)

AdaptiveCard(type="AdaptiveCard", version="1.5", body=body, actions=actions_list)


def test_construct_from_dict():
def contruct_from_dict():
AdaptiveCard.model_validate(
{
"type": "AdaptiveCard",
Expand Down Expand Up @@ -169,10 +169,10 @@ def test_construct_from_json_string():
},
"body": [
{"type": "TextBlock", "text": "Migrations Ready"},
{"type": "TextBlock", "text": "Submitted by **REDACTED**"},
{"type": "TextBlock", "text": "Submitted by **ADACO**"},
{
"type": "TextBlock",
"text": "Approval pending from **REDACTED**"
"text": "Approval pending from **DDM**"
}
],
"actions": [
Expand Down