Skip to content

Commit

Permalink
Merge pull request #17 from Ctri-The-Third/update_card_to_new_list
Browse files Browse the repository at this point in the history
Update card to new list
  • Loading branch information
Ctri-The-Third authored Oct 24, 2022
2 parents 731291f + b45ec7b commit fb01241
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ env:
JIRA_HOST_1: ${{secrets.JIRA_HOST_1}}
JIRA_KEY_1: ${{secrets.JIRA_KEY_1}}
SLACK_TOKEN: ${{secrets.SLACK_TOKEN}}
TRELLO_KEY: ${{secrets.TRELLO_KEY}}
TRELLO_TOKEN: ${{secrets.TRELLO_TOKEN}}
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
Expand Down
8 changes: 5 additions & 3 deletions serviceHelpers/trello.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, board_id, key, token) -> None:
self.dirty_cache = True
pass

def find_trello_card(self, regex):
def find_trello_card(self, regex) -> dict:
"uses regexes to search name and description of cached / fetched cards. Returns the first it finds."
cards = self.fetch_trello_cards() if self.dirty_cache else self._cached_cards

Expand Down Expand Up @@ -188,15 +188,17 @@ def create_card(self,title, list_id, description = None, labelID = None, dueTim
return card


def update_card( self, card_id, title, description = None, pos = None):

def update_card( self, card_id:str, title:str, description:str = None, pos:float = None, new_list_id:str = None):
"Update the card with a new title, description, position. use list_id to move to another list. "
params = self._get_trello_params()
params["name"] = title

if description is not None:
params["desc"] =description
if pos is not None:
params["pos"] = pos
if new_list_id is not None:
params["idList"] = new_list_id
url = "https://api.trello.com/1/cards/%s" % (card_id)
r = requests.put(url,params=params)
if r.status_code != 200:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setup(
name="hex-helpers",
version="2.7.1",
version="2.7.2",
description="A series of light helpers for `freshdesk`,`gmail`,`habitica`,`hue lights`,`jira`,`slack`,`trello`",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
12 changes: 12 additions & 0 deletions tests/test_trello_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

TEST_BOARD_ID = "5f0dee6c5026590ce300472c"
TEST_LIST_ID = "5f0dee6c5026590ce3004732"
TEST_LIST_ID_TWO = "61d8367af7a2942f50afd468"

def test_trello_sort():
helper = trello("none","none","none")
Expand Down Expand Up @@ -103,3 +104,14 @@ def test_create_card_at_correct_position():

card = helper.create_card("TEST CARD, PLEASE IGNORE",TEST_LIST_ID,"A temporary card that should get deleted",position=-1)
helper.deleteTrelloCard(card["id"])

def test_move_card_from_list_to_list():
helper = trello(TEST_BOARD_ID,os.environ["TRELLO_KEY"],os.environ["TRELLO_TOKEN"])
card = helper.create_card("TEST CARD, PLEASE IGNORE",TEST_LIST_ID)
helper.update_card(card["id"], card["name"],new_list_id=TEST_LIST_ID_TWO)
new_card = helper.fetch_trello_card(card["id"])

helper.deleteTrelloCard(new_card["id"])
assert card["id"] == new_card["id"]
assert new_card.get("idList","") == TEST_LIST_ID_TWO

2 changes: 1 addition & 1 deletion tests/test_zendesk.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def test_get_user(caplog):
assert entry.levelno < logging.ERROR
assert isinstance(user, ZendeskUser)

assert user.name == "Mat Perry"
assert user.name == "test test"
assert user.email == "[email protected]"
assert user.user_id == 417316391
assert user.organisationID is None
Expand Down

0 comments on commit fb01241

Please sign in to comment.