-
Notifications
You must be signed in to change notification settings - Fork 22
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 #550 from golemfactory/az/service-cluster-properties
Read-only properties for some Service/Cluster private fields
- Loading branch information
Showing
3 changed files
with
63 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"""Unit tests for `yapapi.engine` module.""" | ||
from unittest.mock import Mock | ||
|
||
import pytest | ||
|
||
from yapapi import Golem | ||
import yapapi.engine | ||
import yapapi.rest | ||
|
||
|
||
@pytest.fixture(autouse=True) | ||
def mock_rest_configuration(monkeypatch): | ||
"""Mock `yapapi.rest.Configuration`.""" | ||
monkeypatch.setattr(yapapi.rest, "Configuration", Mock) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"default_subnet, subnet_arg, expected_subnet", | ||
[ | ||
(None, None, None), | ||
("my-little-subnet", None, "my-little-subnet"), | ||
(None, "whole-golem", "whole-golem"), | ||
("my-little-subnet", "whole-golem", "whole-golem"), | ||
], | ||
) | ||
def test_set_subnet_tag(default_subnet, subnet_arg, expected_subnet, monkeypatch): | ||
"""Check that `subnet_tag` argument takes precedence over `yapapi.engine.DEFAULT_SUBNET`.""" | ||
|
||
monkeypatch.setattr(yapapi.engine, "DEFAULT_SUBNET", default_subnet) | ||
|
||
if subnet_arg is not None: | ||
golem = Golem(budget=1.0, subnet_tag=subnet_arg) | ||
else: | ||
golem = Golem(budget=1.0) | ||
assert golem.subnet_tag == expected_subnet |
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