Skip to content

Commit

Permalink
tests: Add child and multi-type creation tests
Browse files Browse the repository at this point in the history
Does not include multiple projects since our test data
doesn't have multiple projects and isn't written that
way at the moment.

The pycontribs/jira project utilizes a test environment
which spawns an instance of Jira Server live during CI.
We may want to consider pivoting how we do CI to that
model so we don't keep having to fabricate what Jira
would do.
  • Loading branch information
lhh committed Feb 2, 2024
1 parent 8dbd56d commit d55895e
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions jirate/tests/test_jira_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,3 +169,37 @@ def test_create_from_template_customfield():
assert issue == [{'parent': 'TEST-2'}]
issue = fake_jirate.issue('TEST-2')
assert issue == {'key': 'TEST-2', 'raw': {'fields': {'description': 'Test of custom field transmogrify', 'issuetype': 'Task', 'customfield_1234567': 'abc123', 'project': {'key': 'TEST'}, 'summary': 'custom field test'}}}


def test_create_from_template_subtasks():
# TEST-3/4 pop out because we are reusing the above fake_jirate
template = {'issues': [
{'summary': 'Sub Tasks Check',
'issuetype': 'Task',
'subtasks': [
{'summary': 'Child Task'}
]}]}

_create_from_template(args, template)
# Creates TEST-3 and TEST-4
assert fake_jirate.issue('TEST-3') == {'key': 'TEST-3', 'raw': {'fields': {'issuetype': 'Task', 'project': {'key': 'TEST'}, 'summary': 'Sub Tasks Check'}}}
assert fake_jirate.issue('TEST-4') == {'key': 'TEST-4', 'raw': {'fields': {'issuetype': 'Sub-task', 'parent': 'TEST-3', 'project': {'key': 'TEST'}, 'summary': 'Child Task'}}}


def test_create_from_template_multiple_types():
# TEST-5/6 pop out because we are reusing the above fake_jirate
template = {'issues': [
{'summary': 'Multitype1',
'issuetype': 'Task'
},
{'summary': 'Multitype2',
'issuetype': 'Bug',
'subtasks': [
{'summary': 'Bug Subtask'}
]}]}

_create_from_template(args, template)
# Creates TEST-5 and TEST-6
assert fake_jirate.issue('TEST-5') == {'key': 'TEST-5', 'raw': {'fields': {'issuetype': 'Task', 'project': {'key': 'TEST'}, 'summary': 'Multitype1'}}}
assert fake_jirate.issue('TEST-6') == {'key': 'TEST-6', 'raw': {'fields': {'issuetype': 'Bug', 'project': {'key': 'TEST'}, 'summary': 'Multitype2'}}}
assert fake_jirate.issue('TEST-7') == {'key': 'TEST-7', 'raw': {'fields': {'issuetype': 'Sub-task', 'project': {'key': 'TEST'}, 'parent': 'TEST-6', 'summary': 'Bug Subtask'}}}

0 comments on commit d55895e

Please sign in to comment.