mirror of
https://github.com/saltstack/salt.git
synced 2025-04-16 09:40:20 +00:00
Add testcases for mongo ext_pillar and returner
This commit is contained in:
parent
db50e0c3b9
commit
746af307d9
2 changed files with 61 additions and 0 deletions
30
tests/pytests/unit/pillar/test_mongo.py
Normal file
30
tests/pytests/unit/pillar/test_mongo.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import pytest
|
||||
|
||||
import salt.exceptions
|
||||
import salt.pillar.mongo as mongo
|
||||
from tests.support.mock import patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
|
||||
return {
|
||||
mongo: {
|
||||
"__opts__": {
|
||||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
def test_config_exception():
|
||||
opts = {
|
||||
"mongo.host": "localhost",
|
||||
"mongo.port": 27017,
|
||||
"mongo.user": "root",
|
||||
"mongo.password": "pass",
|
||||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin",
|
||||
}
|
||||
with patch.dict(mongo.__opts__, opts):
|
||||
with pytest.raises(salt.exceptions.SaltConfigurationError):
|
||||
mongo.ext_pillar("minion1", {})
|
31
tests/pytests/unit/returners/test_mongo_future_return.py
Normal file
31
tests/pytests/unit/returners/test_mongo_future_return.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
import pytest
|
||||
|
||||
import salt.exceptions
|
||||
import salt.returners.mongo_future_return as mongo
|
||||
from tests.support.mock import patch
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def configure_loader_modules():
|
||||
|
||||
return {
|
||||
mongo: {
|
||||
"__opts__": {
|
||||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@patch("salt.returners.mongo_future_return.PYMONGO_VERSION", "4.3.2", create=True)
|
||||
def test_config_exception():
|
||||
opts = {
|
||||
"mongo.host": "localhost",
|
||||
"mongo.port": 27017,
|
||||
"mongo.user": "root",
|
||||
"mongo.password": "pass",
|
||||
"mongo.uri": "mongodb://root:pass@localhost27017/salt?authSource=admin",
|
||||
}
|
||||
with patch.dict(mongo.__opts__, opts):
|
||||
with pytest.raises(salt.exceptions.SaltConfigurationError):
|
||||
mongo.returner({})
|
Loading…
Add table
Reference in a new issue