本文整理汇总了Python中trello.TrelloClient.list_hooks方法的典型用法代码示例。如果您正苦于以下问题:Python TrelloClient.list_hooks方法的具体用法?Python TrelloClient.list_hooks怎么用?Python TrelloClient.list_hooks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类trello.TrelloClient
的用法示例。
在下文中一共展示了TrelloClient.list_hooks方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_client
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_hooks [as 别名]
def get_client(self):
client = None
while client is None:
self._set_creds()
client = TrelloClient(api_key=self._api_key, token=self._token)
try:
client.list_hooks(self._token)
except Unauthorized:
print('Trello client is not authorized.')
client = None
self._write_config()
print('Trello client successfully authorized.')
return client
示例2: main
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_hooks [as 别名]
def main():
try:
parser = argparse.ArgumentParser(description="Webhook helpers")
parser.add_argument('--cleanup', dest='cleanup', action='store_true', help='delete webhook from your SETTINGS.')
parser.add_argument('--update', dest='update', action='store_true', help='upsert webhook from your SETTINGS.')
parser.add_argument('--init', dest='init', action='store_true', help='delete and create webhook from your SETTINGS.')
args = parser.parse_args()
if not args.cleanup and not args.update and not args.init:
print parser.print_help()
sys.exit(0)
client = TrelloClient(api_key=SETTINGS['trello_api_key'], token=SETTINGS['trello_api_token'])
trello_boards = client.list_boards()
boards_name = [slugify(b['name']) for b in SETTINGS.get('boards', {}).values()]
# cleanup part
if args.cleanup or args.init:
result = [h.delete() for h in client.list_hooks()]
LOGGING.info('delete {} webhook'.format(len(result)))
# update / init part
if args.update or args.init:
for board in trello_boards:
board_name = slugify(board.name)
if board_name not in boards_name:
continue
LOGGING.info('try to create webhook board :: {}'.format(board_name))
url = SETTINGS['callback_url'] + '/trelloCallbacks/'
result = client.create_hook(url, board.id)
LOGGING.info('create webhook board :: {} :: {}'.format(board_name, result))
except Exception as e:
LOGGING.error('unable init webhook :: {}'.format(e))
sys.exit(1)
示例3: TrelloClientTestCase
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_hooks [as 别名]
class TrelloClientTestCase(unittest.TestCase):
"""
Tests for TrelloClient API. Note these test are in order to
preserve dependencies, as an API integration cannot be tested
independently.
"""
def setUp(self):
self._trello = TrelloClient(os.environ['TRELLO_API_KEY'],
token=os.environ['TRELLO_TOKEN'])
def test01_list_boards(self):
self.assertEqual(
len(self._trello.list_boards(board_filter="open")),
int(os.environ['TRELLO_TEST_BOARD_COUNT']))
def test10_board_attrs(self):
boards = self._trello.list_boards()
for b in boards:
self.assertIsNotNone(b.id, msg="id not provided")
self.assertIsNotNone(b.name, msg="name not provided")
self.assertIsNotNone(b.description, msg="description not provided")
self.assertIsNotNone(b.closed, msg="closed not provided")
self.assertIsNotNone(b.url, msg="url not provided")
def test20_board_all_lists(self):
boards = self._trello.list_boards()
for b in boards:
try:
b.all_lists()
except Exception:
self.fail("Caught Exception getting lists")
def test21_board_open_lists(self):
boards = self._trello.list_boards()
for b in boards:
try:
b.open_lists()
except Exception:
self.fail("Caught Exception getting open lists")
def test22_board_closed_lists(self):
boards = self._trello.list_boards()
for b in boards:
try:
b.closed_lists()
except Exception:
self.fail("Caught Exception getting closed lists")
def test30_list_attrs(self):
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
self.assertIsNotNone(l.id, msg="id not provided")
self.assertIsNotNone(l.name, msg="name not provided")
self.assertIsNotNone(l.closed, msg="closed not provided")
break # only need to test one board's lists
def test50_list_cards(self):
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
for c in l.list_cards():
self.assertIsNotNone(c.id, msg="id not provided")
self.assertIsNotNone(c.name, msg="name not provided")
self.assertIsNotNone(c.description,
msg="description not provided")
self.assertIsNotNone(c.closed, msg="closed not provided")
self.assertIsNotNone(c.url, msg="url not provided")
break
break
pass
def test51_fetch_cards(self):
"""
Tests fetching all attributes for all cards
"""
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
for c in l.list_cards():
c.fetch()
self.assertIsInstance(c.date_last_activity, datetime,
msg='date not provided')
self.assertTrue(len(c.board_id) > 0,
msg='board id not provided')
break
break
pass
def test52_list_hooks(self):
self.assertIsInstance(self._trello.list_hooks(), list)
def test53_unauthorized(self):
client = TrelloClient('a')
self.assertRaises(Unauthorized,
client.list_boards)
#.........这里部分代码省略.........
示例4: TrelloClientTestCase
# 需要导入模块: from trello import TrelloClient [as 别名]
# 或者: from trello.TrelloClient import list_hooks [as 别名]
class TrelloClientTestCase(unittest.TestCase):
"""
Tests for TrelloClient API. Note these test are in order to
preserve dependencies, as an API integration cannot be tested
independently.
"""
def setUp(self):
self._trello = TrelloClient(os.environ["TRELLO_API_KEY"], token=os.environ["TRELLO_TOKEN"])
def test01_list_boards(self):
self.assertEquals(len(self._trello.list_boards()), int(os.environ["TRELLO_TEST_BOARD_COUNT"]))
def test10_board_attrs(self):
boards = self._trello.list_boards()
for b in boards:
self.assertIsNotNone(b.id, msg="id not provided")
self.assertIsNotNone(b.name, msg="name not provided")
self.assertIsNotNone(b.description, msg="description not provided")
self.assertIsNotNone(b.closed, msg="closed not provided")
self.assertIsNotNone(b.url, msg="url not provided")
def test20_board_all_lists(self):
boards = self._trello.list_boards()
for b in boards:
try:
b.all_lists()
except Exception:
self.fail("Caught Exception getting lists")
def test21_board_open_lists(self):
boards = self._trello.list_boards()
for b in boards:
try:
b.open_lists()
except Exception:
self.fail("Caught Exception getting open lists")
def test22_board_closed_lists(self):
boards = self._trello.list_boards()
for b in boards:
try:
b.closed_lists()
except Exception:
self.fail("Caught Exception getting closed lists")
def test30_list_attrs(self):
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
self.assertIsNotNone(l.id, msg="id not provided")
self.assertIsNotNone(l.name, msg="name not provided")
self.assertIsNotNone(l.closed, msg="closed not provided")
break # only need to test one board's lists
def test50_list_cards(self):
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
for c in l.list_cards():
self.assertIsNotNone(c.id, msg="id not provided")
self.assertIsNotNone(c.name, msg="name not provided")
self.assertIsNotNone(c.description, msg="description not provided")
self.assertIsNotNone(c.closed, msg="closed not provided")
self.assertIsNotNone(c.url, msg="url not provided")
break
break
pass
def test51_fetch_cards(self):
"""
Tests fetching all attributes for all cards
"""
boards = self._trello.list_boards()
for b in boards:
for l in b.all_lists():
for c in l.list_cards():
c.fetch()
self.assertIsInstance(c.date_last_activity, datetime, msg="date not provided")
self.assertTrue(len(c.board_id) > 0, msg="board id not provided")
break
break
pass
def test52_list_hooks(self):
self.assertIsInstance(self._trello.list_hooks(), list)
def test53_unauthorized(self):
client = TrelloClient("a")
self.assertRaises(Unauthorized, client.list_boards)
def test54_resource_unavailable(self):
self.assertRaises(ResourceUnavailable, self._trello.get_card, "0")