1
0
This commit is contained in:
Jon Michael Aanes 2024-10-02 10:32:14 +02:00
parent 9fff7b972f
commit 4dd1b79f54
4 changed files with 22 additions and 16 deletions

View File

@ -34,6 +34,7 @@ URL_GET_TAG = URL_API_ROOT + '/tags/{tag_id}'
URL_GET_CUSTOM_FIELD = URL_API_ROOT + '/customfields/{custom_field_id}'
URL_GET_TASKS = URL_API_ROOT + '/tasks'
class CardCache:
def __init__(self):
self.cards = []

View File

@ -48,10 +48,12 @@ class WidgetCommonId:
class CustomFieldItemId:
raw_id: str
@dataclasses.dataclass(frozen=True)
class TaskId:
raw_id: str
@dataclasses.dataclass(frozen=True)
class TaskListId:
raw_id: str
@ -146,13 +148,13 @@ class CustomFieldInfo:
@staticmethod
def from_json(json: dict[str, Any]) -> 'CustomFieldInfo':
return CustomFieldInfo(
organization_id= OrganizationId(json['organizationId']),
custom_field_id= CustomFieldId(json['customFieldId']),
widget_common_id= WidgetCommonId(json['widgetCommonId']),
type= json['type'],
name= json['name'],
enabled= json['enabled'],
custom_field_items= json['customFieldItems'],
organization_id=OrganizationId(json['organizationId']),
custom_field_id=CustomFieldId(json['customFieldId']),
widget_common_id=WidgetCommonId(json['widgetCommonId']),
type=json['type'],
name=json['name'],
enabled=json['enabled'],
custom_field_items=json['customFieldItems'],
)
@ -185,6 +187,7 @@ class CardDependency:
CardId(json['reverseCardId']),
)
@dataclasses.dataclass(frozen=True)
class Task:
task_id: TaskId
@ -198,15 +201,16 @@ class Task:
@staticmethod
def from_json(json: dict[str, Any]) -> 'Task':
return Task(
task_id = json['taskId'],
task_list_id = json['taskListId'],
organization_id = json['organizationId'],
card_common_id = json['cardCommonId'],
name = json['name'],
completed = json['completed'],
position = json['position'],
task_id=json['taskId'],
task_list_id=json['taskListId'],
organization_id=json['organizationId'],
card_common_id=json['cardCommonId'],
name=json['name'],
completed=json['completed'],
position=json['position'],
)
@dataclasses.dataclass(frozen=True)
class Card:
card_id: CardId

View File

@ -61,8 +61,7 @@ class CardFileSystemItem(FileSystemItem):
def to_card_contents(card: Card, favro_client: FavroClient) -> str:
tags = [favro_client.get_tag(tag_id).name for tag_id in card.tags]
assignments = [
favro_client.get_user(assignment.user).name
for assignment in card.assignments
favro_client.get_user(assignment.user).name for assignment in card.assignments
]
dependencies = [
CARD_FILENAME_FORMAT.format(

View File

@ -1,4 +1,5 @@
import pytest
from favro_sync.favro_markdown import CardFileFormatter
EXAMPLE_TEXT_1 = """
@ -60,6 +61,7 @@ EXAMPLES = [EXAMPLE_TEXT_1, EXAMPLE_TEXT_2, EXAMPLE_TEXT_3]
FORMATTER = CardFileFormatter()
@pytest.mark.parametrize('example_text', EXAMPLES)
def test_parse_and_render(example_text: str):
card_contents = FORMATTER.parse_card_contents(example_text)