-
Notifications
You must be signed in to change notification settings - Fork 313
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
17 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,29 @@ | ||
from unittest.mock import MagicMock | ||
from unittest.mock import MagicMock, patch | ||
|
||
import pytest | ||
|
||
from esrally import rally | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"offline,probing_url,subcommand,expected", | ||
"offline,has_conn,subcommand,expected", | ||
[ | ||
(True, "https://github.com", "info", True), | ||
(True, "http://invalid", "info", True), | ||
(False, "https://github.com", "info", True), | ||
(False, "http://invalid", "info", False), | ||
(False, "http://github.com", "list", True), | ||
(False, "http://invalid", "list", True), | ||
# command that needs internet | ||
(True, True, "info", True), | ||
(True, False, "info", True), | ||
(False, True, "info", True), | ||
(False, False, "info", False), | ||
# command that doesn't need internet | ||
(True, True, "list", True), | ||
(True, False, "list", True), | ||
(False, True, "list", True), | ||
(False, False, "list", True), | ||
], | ||
) | ||
def test_ensure_internet_connection(offline, probing_url, subcommand, expected): | ||
def test_ensure_internet_connection(offline, has_conn, subcommand, expected): | ||
args = MagicMock(offline=offline, subcommand=subcommand) | ||
logger = MagicMock() | ||
cfg = MagicMock() | ||
cfg.opts = MagicMock(return_value=probing_url) | ||
|
||
assert rally.ensure_internet_connection(args, cfg, logger) == expected | ||
with patch("esrally.rally.net.has_internet_connection", MagicMock(return_value=has_conn)): | ||
assert rally.ensure_internet_connection(args, cfg, logger) == expected |