Issue.create: Use consistent method signature

parent ddb9164f
......@@ -2,6 +2,7 @@
This contains the Issue implementation for GitHub.
"""
from datetime import datetime
from typing import Optional
from typing import Set
import re
......@@ -394,7 +395,7 @@ class GitHubIssue(GitHubMixin, Issue):
@staticmethod
def create(token: str, repository: str,
title: str, body: str=''):
title: str, body: str='', issue_type: Optional[str]=None):
"""
Create a new issue with given title and body.
......
......@@ -3,6 +3,7 @@ This contains the Issue implementation for GitLab.
"""
from datetime import datetime
from typing import List
from typing import Optional
from typing import Set
from typing import Union
from urllib.parse import quote_plus
......@@ -399,7 +400,9 @@ class GitLabIssue(GitLabMixin, Issue):
@staticmethod
def create(token: Union[GitLabOAuthToken, GitLabPrivateToken],
repository: str,
title: str, body: str=''):
title: str,
body: str='',
issue_type: Optional[str]=None):
"""
Create a new issue with given title and body.
......
......@@ -201,7 +201,7 @@ class Issue(IGittObject):
raise NotImplementedError
@staticmethod
def create(token, repository, title, body=''):
def create(token, repository, title, body='', issue_type=None):
"""
Create a new issue in repository.
"""
......
......@@ -3,6 +3,7 @@ This contains the Issue implementation for Jira.
"""
from datetime import datetime
from typing import List
from typing import Optional
from typing import Set
from typing import Union
from urllib.parse import urljoin
......@@ -264,9 +265,9 @@ class JiraIssue(JiraMixin, Issue):
@staticmethod
def create(token: JiraOAuth1Token,
project: str,
issue_type: str,
title: str,
body: str):
body: str='',
issue_type: Optional[str]=None):
"""
Creates a new issue with the given title and body on the specified
project.
......@@ -284,6 +285,8 @@ class JiraIssue(JiraMixin, Issue):
:return:
A new JiraIssue object.
"""
if not issue_type:
raise TypeError('`issue_type` cannot be empty.')
post_url = '/issue/'
data = {
'description': body,
......
......@@ -71,8 +71,10 @@ class JiraIssueTest(IGittTestCase):
self.iss.reopen()
def test_issue_create(self):
with self.assertRaises(TypeError):
iss = JiraIssue.create(self.token, 10001, 'title', 'body')
iss = JiraIssue.create(
self.token, 10001, 'Task', 'test title', 'test body')
self.token, 10001, 'test title', 'test body', 'Task')
self.assertEqual(iss.state, IssueStates.OPEN)
self.assertEqual(iss.title, 'test title')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment