generated from CorrelAid/python-bare-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor all tests to use python-mock (#72)
* refactor all tests to use python-mock * update mocks
- Loading branch information
Showing
7 changed files
with
118 additions
and
129 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import re | ||
from pathlib import Path | ||
from typing import Optional | ||
|
||
import pytest | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,45 @@ | ||
from mock import patch | ||
|
||
from pygenesis.helloworld import logincheck, whoami | ||
from tests.test_http_helper import _generic_request_status | ||
|
||
|
||
@patch("requests.get") | ||
@patch("pygenesis.helloworld.load_config") | ||
def test_whoami(mock_config, mock_requests): | ||
mock_config.return_value = { | ||
"GENESIS API": { | ||
"base_url": "mocked_url", | ||
"username": "JaneDoe", | ||
"password": "password", | ||
} | ||
} | ||
mock_requests.return_value = _generic_request_status() | ||
|
||
whoami() | ||
|
||
|
||
@patch("requests.get") | ||
@patch("pygenesis.helloworld.load_config") | ||
def test_logincheck(mock_config, mock_requests): | ||
mock_config.return_value = { | ||
"GENESIS API": { | ||
"base_url": "mocked_url", | ||
"username": "JaneDoe", | ||
"password": "password", | ||
} | ||
} | ||
mock_requests.return_value = _generic_request_status() | ||
|
||
logincheck() | ||
def test_whoami(mocker): | ||
mocker.patch( | ||
"pygenesis.helloworld.load_config", | ||
return_value={ | ||
"GENESIS API": { | ||
"base_url": "mocked_url", | ||
"username": "JaneDoe", | ||
"password": "password", | ||
} | ||
}, | ||
) | ||
|
||
mocker.patch( | ||
"pygenesis.helloworld.requests.get", | ||
return_value=_generic_request_status(), | ||
) | ||
|
||
response = whoami() | ||
|
||
assert response == str(_generic_request_status().text) | ||
|
||
|
||
def test_logincheck(mocker): | ||
mocker.patch( | ||
"pygenesis.helloworld.load_config", | ||
return_value={ | ||
"GENESIS API": { | ||
"base_url": "mocked_url", | ||
"username": "JaneDoe", | ||
"password": "password", | ||
} | ||
}, | ||
) | ||
mocker.patch( | ||
"pygenesis.helloworld.requests.get", | ||
return_value=_generic_request_status(), | ||
) | ||
|
||
response = logincheck() | ||
|
||
assert response == str(_generic_request_status().text) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.