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_CUSTOM_FIELD = URL_API_ROOT + '/customfields/{custom_field_id}'
URL_GET_TASKS = URL_API_ROOT + '/tasks' URL_GET_TASKS = URL_API_ROOT + '/tasks'
class CardCache: class CardCache:
def __init__(self): def __init__(self):
self.cards = [] self.cards = []

View File

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

View File

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

View File

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