G
G
GSnick2020-04-04 16:26:33
Python
GSnick, 2020-04-04 16:26:33

How to write mock for Jira connector?

There is a piece of code that returns a jira object with which the rest of the functions work in the future. I can’t write tests for other functions, because I can’t figure out how, in principle, to lock an object of this kind in pytest?

#!/usr/bin/env python3.7
import os
from jira import JIRA

def jira_connector(url=os.environ["JIRA_URL"], j_user=os.environ["JIRA_USER"], j_pass=os.environ["JIRA_PASS"]):
    jira_options = {'server': url}
    jira = JIRA(options=jira_options, basic_auth=(
        j_user, j_pass), logging=True, timeout=10)
    return jira


Connoisseurs, please direct to an article / book or somewhere else. So far, I managed to look through the book Python Testing with pytest
by Brian Okken, but rather simple cases are considered there and I did not find an answer.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question