Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def get_issue(
self, templates=None, issue=None, description=None, add_tags=None
):
templates = {} if templates is None else templates
origin = {
'annotation_length': 100, # Arbitrary
'default_priority': 'H', # Arbitrary
'description_length': 100, # Arbitrary
'templates': templates,
'shorten': False, # Arbitrary
'add_tags': add_tags if add_tags else [],
}
issue = Issue({}, origin)
issue.to_taskwarrior = lambda: (
self.arbitrary_issue if description is None else description
)
issue.get_default_description = lambda: (
self.arbitrary_default_description
if description is None else description
)
return issue
def test_aslist(self):
self.assertEqual(
config.aslist('project_bar,project_baz'),
['project_bar', 'project_baz']
)
def test_aslist_jinja(self):
self.assertEqual(
config.aslist("work, jira, {{jirastatus|lower|replace(' ','_')}}"),
['work', 'jira', "{{jirastatus|lower|replace(' ','_')}}"]
)
def test_get_lists_exclude(self):
self.config.set('mytrello', 'trello.exclude_lists', 'List 1')
service = TrelloService(self.config, 'general', 'mytrello')
lists = service.get_lists('B04RD')
self.assertEqual(list(lists), [self.LIST2])
def test_valid_config_no_access_token(self, die):
self.config.remove_option('mytrello', 'trello.token')
TrelloService.validate_config(self.service_config, 'mytrello')
die.assert_called_with("[mytrello] has no 'trello.token'")
def setUp(self):
super(TestTrelloService, self).setUp()
self.config = configparser.RawConfigParser()
self.config.add_section('general')
self.config.add_section('mytrello')
self.config.set('mytrello', 'trello.api_key', 'XXXX')
self.config.set('mytrello', 'trello.token', 'YYYY')
self.service_config = ServiceConfig(
TrelloService.CONFIG_PREFIX, self.config, 'mytrello')
responses.add(responses.GET,
'https://api.trello.com/1/lists/L15T/cards/open',
json=[self.CARD1, self.CARD2, self.CARD3])
responses.add(responses.GET,
'https://api.trello.com/1/boards/B04RD/lists/open',
json=[self.LIST1, self.LIST2])
responses.add(responses.GET,
'https://api.trello.com/1/boards/F00',
json={'id': 'F00', 'name': 'Foo Board'})
responses.add(responses.GET,
'https://api.trello.com/1/boards/B4R',
json={'id': 'B4R', 'name': 'Bar Board'})
responses.add(responses.GET,
'https://api.trello.com/1/members/me/boards',
json=[self.BOARD])
responses.add(responses.GET,
def test_get_lists_include(self):
self.config.set('mytrello', 'trello.include_lists', 'List 1')
service = TrelloService(self.config, 'general', 'mytrello')
lists = service.get_lists('B04RD')
self.assertEqual(list(lists), [self.LIST1])
def test_annotations(self):
service = TrelloService(self.config, 'general', 'mytrello')
annotations = service.annotations(self.CARD1)
self.assertEqual(
list(annotations), ["@luidgi - Preums", "@mario - Deuz"])
def test_get_cards_assigned_unassigned(self):
self.config.set('mytrello', 'trello.only_if_assigned', 'tintin')
self.config.set('mytrello', 'trello.also_unassigned', 'true')
service = TrelloService(self.config, 'general', 'mytrello')
cards = service.get_cards('L15T')
self.assertEqual(list(cards), [self.CARD1, self.CARD3])
def test_get_cards(self):
service = TrelloService(self.config, 'general', 'mytrello')
cards = service.get_cards('L15T')
self.assertEqual(list(cards), [self.CARD1, self.CARD2, self.CARD3])