Skip to content

Commit

Permalink
Add components support to JIRA
Browse files Browse the repository at this point in the history
It's now possible to add "components" argument when creating/updating
JIRAs
  • Loading branch information
Stanislav Ochotnicky authored and dmranck committed Sep 5, 2018
1 parent 965798b commit 4ef29f0
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 1 deletion.
3 changes: 2 additions & 1 deletion read-the-docs/source/JIRA.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ particular JIRA instance during ticket creation:
duedate='2017-01-13'
parent='KEY-XX'
customfield_XXXXX='Custom field text'
components=['component1', 'component2']
While creating a Sub task, parent ticket id is required, otherwise create()
method fails with KeyError - "Parent field is required while creating a Sub
Task"
Task". Components are referenced using their names.

edit()
------
Expand Down
11 changes: 11 additions & 0 deletions tests/test_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,17 @@ def test_prepare_ticket_fields_no_parent(self):
with self.assertRaises(KeyError):
jira._prepare_ticket_fields(fields)

def test_prepare_ticket_fields_components(self):
fields = {'components': ["c1", "c2"]}
expected_fields = {
'components': [
{"name": "c1"},
{"name": "c2"}
]
}
prepared_fields = jira._prepare_ticket_fields(fields)
self.assertEqual(prepared_fields, expected_fields)


if __name__ == '__main__':
main()
4 changes: 4 additions & 0 deletions ticketutil/jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,10 @@ def _prepare_ticket_fields(fields):
fields[key] = {'name': value}
if key in ['parent']:
fields[key] = {'key': value}
if key in ['components']:
# we take in list of strings (names) and turn it into list of
# dicts with key "name" and value of the component name
fields[key] = [{"name": name} for name in fields[key]]
if key == 'type':
fields['issuetype'] = {'name': value}
fields.pop('type')
Expand Down

0 comments on commit 4ef29f0

Please sign in to comment.