Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to write unit tests for code written using python jira api?

Surya October 20, 2020

I'm looking to write unit tests for the following code. Please help me figure out the solution.

def jiraConnect(username, password):

try:
logger.info("Connecting to Jira")
jira = JIRA(basic_auth = (username, password), options = {'server':'<ip-address/url>'})
logger.info("Connected to Jira")
return jira
except JIRAError as e:
return e.status_code, e.text

def getIssues(jql, field_list):
try:
size = 100
initial = 0
allIssues = []
while True:
start = initial*size
issues = jc.search_issues(f"{jql}", start, size, fields = field_list)
if(len(issues)==0:
break
initial += 1
for issue in issues:
allIssues.append(issue)
return allIssues
except JIRAError as e:
return e.status_code, e.text

 

1 answer

0 votes
Gonchik Tsymzhitov
Community Champion
January 28, 2021

Suggest an answer

Log in or Sign up to answer