-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
80e0e53
commit e33d644
Showing
6 changed files
with
194 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
::: endpoints.board_card_types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,91 @@ | ||
from .boards import Boards | ||
from .generics import GenericRequestMethod | ||
from kanbanize_sdk.dataclasses import BoardCardTypesInsertBody, BoardCardTypesUpdateBody | ||
|
||
|
||
class BoardCardTypes(Boards): | ||
... | ||
class BoardCardTypes(GenericRequestMethod): | ||
""" | ||
Class responsible to make calls to Kanbanize board card types endpoints | ||
""" | ||
|
||
endpoint = '/boards' | ||
|
||
def list(self, board_id: int, *args, **kwargs) -> list: | ||
""" | ||
This method is responsible to list all board card types from the board into the platform. | ||
Parameters: | ||
board_id: An integer parameter that represents the board assignee | ||
Returns: | ||
An array of objects that represents the board card types | ||
""" | ||
return self.service.get(self.endpoint + f'/{board_id}/cardTypes') | ||
|
||
def get(self, board_id: int, type_id: int, *args, **kwargs) -> dict: | ||
""" | ||
This method is responsible to get a board card types from the board into the platform. | ||
Parameters: | ||
board_id: An integer parameter that represents the board identification. | ||
type_id: An integer parameter that represents the user identification. | ||
Returns: | ||
A board card type object with the basic information data. | ||
""" | ||
return self.service.get(self.endpoint + f'/{board_id}/cardTypes/{type_id}') | ||
|
||
def get_effective_settings(self, board_id: int, type_id: int, *args, **kwargs) -> dict: | ||
""" | ||
This method is responsible to get a board card type settings from the board into the platform. | ||
Parameters: | ||
board_id: An integer parameter that represents the board identification. | ||
type_id: An integer parameter that represents the user identification. | ||
Returns: | ||
A board card type settings object with the basic information data. | ||
""" | ||
return self.service.get(self.endpoint + f'/{board_id}/cardTypes/{type_id}/effectiveSettings') | ||
|
||
def insert(self, board_id: int, type_id: int, body: BoardCardTypesInsertBody, *args, **kwargs) -> dict: | ||
|
||
""" | ||
This method is responsible to get a board card types from the board into the platform. | ||
Parameters: | ||
board_id: An integer parameter that represents the board identification. | ||
type_id: An integer parameter that represents the user identification. | ||
body: It's a dataclass object that provide the essential request body needed to update a board card types to the | ||
board into the platform. | ||
Returns: | ||
An object that represents the board card type. | ||
""" | ||
return self.service.put(self.endpoint + f'/{board_id}/cardTypes/{type_id}', data=body.to_dict()) | ||
|
||
def update(self, board_id: int, type_id: int, body: BoardCardTypesUpdateBody, *args, **kwargs) -> dict: | ||
|
||
""" | ||
This method is responsible to get a board card types from the board into the platform. | ||
Parameters: | ||
board_id: An integer parameter that represents the board identification. | ||
type_id: An integer parameter that represents the user identification. | ||
body: It's a dataclass object that provide the essential request body needed to update a board card types to the | ||
board into the platform. | ||
""" | ||
return self.service.patch(self.endpoint + f'/{board_id}/cardTypes/{type_id}', data=body.to_dict()) | ||
|
||
def delete(self, board_id: int, type_id: int, *args, **kwargs) -> None: | ||
|
||
""" | ||
This method is responsible to get a board card types from the board into the platform. | ||
Parameters: | ||
board_id: An integer parameter that represents the board identification. | ||
type_id: An integer parameter that represents the user identification. | ||
""" | ||
return self.service.delete(self.endpoint + f'/{board_id}/cardTypes/{type_id}') | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
from pytest import mark | ||
from kanbanize_sdk import Kanbanize, BoardCardTypesInsertBody, BoardCardTypesUpdateBody | ||
|
||
|
||
@mark.board_card_types | ||
def test_list_board_card_types(requests_mock): | ||
test_json = { | ||
'data': [ | ||
{ | ||
"type_id": 0, | ||
"icon_type": 0, | ||
"icon_id": 0, | ||
"color": 'text', | ||
"card_color_sync": 0, | ||
} | ||
] | ||
} | ||
requests_mock.get('https://teste.kanbanize.com/api/v2/boards/1/cardTypes', json=test_json) | ||
service = Kanbanize({'subdomain': 'teste', 'api_key': 'teste_key'}) | ||
assert service.board_card_types().list(board_id=1) == test_json.get('data') | ||
|
||
|
||
@mark.board_card_types | ||
def test_get_board_card_types(requests_mock): | ||
test_json = { | ||
'data': { | ||
"icon_type": 0, | ||
"icon_id": 0, | ||
"color": 'text', | ||
"card_color_sync": 0, | ||
} | ||
} | ||
requests_mock.get('https://teste.kanbanize.com/api/v2/boards/1/cardTypes/1', json=test_json) | ||
service = Kanbanize({'subdomain': 'teste', 'api_key': 'teste_key'}) | ||
assert service.board_card_types().get(board_id=1, type_id=1) == test_json.get('data') | ||
|
||
|
||
@mark.board_card_types | ||
def test_get_board_card_types_settings(requests_mock): | ||
test_json = { | ||
'data': { | ||
"icon_type": 0, | ||
"icon_id": 0, | ||
"color": 'text', | ||
"card_color_sync": 0, | ||
} | ||
} | ||
requests_mock.get('https://teste.kanbanize.com/api/v2/boards/1/cardTypes/1/effectiveSettings', json=test_json) | ||
service = Kanbanize({'subdomain': 'teste', 'api_key': 'teste_key'}) | ||
assert service.board_card_types().get_effective_settings(board_id=1, type_id=1) == test_json.get('data') | ||
|
||
|
||
@mark.board_card_types | ||
def test_insert_board_card_types(requests_mock): | ||
test_json = { | ||
'data': { | ||
"limit_per_board": 0, | ||
"limit_per_card": 0, | ||
} | ||
} | ||
requests_mock.put('https://teste.kanbanize.com/api/v2/boards/1/cardTypes/1', json=test_json) | ||
service = Kanbanize({'subdomain': 'teste', 'api_key': 'teste_key'}) | ||
body = BoardCardTypesInsertBody(icon_type=0, icon_id=0, color='ffffff', card_color_sync=0) | ||
assert service.board_card_types().insert(board_id=1, type_id=1, body=body) == test_json.get('data') | ||
|
||
|
||
@mark.board_card_types | ||
def test_update_board_card_types(requests_mock): | ||
test_json = { | ||
'data': { | ||
"limit_per_board": 0, | ||
"limit_per_card": 0, | ||
} | ||
} | ||
requests_mock.patch('https://teste.kanbanize.com/api/v2/boards/1/cardTypes/1', json=test_json) | ||
service = Kanbanize({'subdomain': 'teste', 'api_key': 'teste_key'}) | ||
body = BoardCardTypesUpdateBody(card_color_sync=0) | ||
assert service.board_card_types().update(1, 1, body) == test_json.get('data') | ||
|
||
|
||
@mark.board_card_types | ||
def test_delete_board_card_types(requests_mock): | ||
requests_mock.delete('https://teste.kanbanize.com/api/v2/boards/1/cardTypes/1', status_code=204) | ||
service = Kanbanize({'subdomain': 'teste', 'api_key': 'teste_key'}) | ||
assert service.board_card_types().delete(1, 1) is None |