-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #107 from HDI-Project/GH_105_remove_flake8_ignores
Gh 105 remove flake8 ignores
- Loading branch information
Showing
16 changed files
with
143 additions
and
106 deletions.
There are no files selected for viewing
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import socket | ||
|
||
import pytest | ||
from mock import patch | ||
|
||
from atm import utilities | ||
|
||
|
||
@patch('atm.utilities.requests') | ||
def test_public_ip_existing(requests_mock): | ||
# Set-up | ||
utilities.public_ip = '1.2.3.4' | ||
|
||
# run | ||
ip = utilities.get_public_ip() | ||
|
||
# asserts | ||
assert ip == utilities.public_ip | ||
requests_mock.get.assert_not_called() | ||
|
||
|
||
def test_public_ip_success(): | ||
# Set-up | ||
utilities.public_ip = None | ||
|
||
# run | ||
ip = utilities.get_public_ip() | ||
|
||
# asserts | ||
assert ip == utilities.public_ip | ||
try: | ||
socket.inet_aton(ip) | ||
except socket.error: | ||
pytest.fail("Invalid IP address") | ||
|
||
|
||
@patch('atm.utilities.requests') | ||
def test_public_ip_fail(requests_mock): | ||
# Set-up | ||
utilities.public_ip = None | ||
requests_mock.get.side_effect = Exception # Force fail | ||
|
||
# run | ||
ip = utilities.get_public_ip() | ||
|
||
# asserts | ||
assert ip == utilities.public_ip | ||
assert ip == 'localhost' | ||
requests_mock.get.assert_called_once_with(utilities.PUBLIC_IP_URL) |
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.