Commit 72a9a9db authored by Daniele Venzano's avatar Daniele Venzano

Fix unit tests

parent c184ec1e
...@@ -24,7 +24,7 @@ import jsonschema ...@@ -24,7 +24,7 @@ import jsonschema
from zoe_lib.exceptions import InvalidApplicationDescription, ZoeLibException from zoe_lib.exceptions import InvalidApplicationDescription, ZoeLibException
import zoe_lib.version import zoe_lib.version
from zoe_lib.config import get_conf import zoe_lib.config
log = logging.getLogger(__name__) log = logging.getLogger(__name__)
...@@ -57,7 +57,7 @@ def app_validate(data): ...@@ -57,7 +57,7 @@ def app_validate(data):
if service['monitor']: if service['monitor']:
found_monitor = True found_monitor = True
service['resources']['memory']['max'] = get_conf().max_memory_limit * (1024 ** 3) service['resources']['memory']['max'] = zoe_lib.config.get_conf().max_memory_limit * (1024 ** 3)
if service['resources']['memory']['min'] is not None and service['resources']['memory']['min'] > service['resources']['memory']['max']: if service['resources']['memory']['min'] is not None and service['resources']['memory']['min'] > service['resources']['memory']['max']:
raise InvalidApplicationDescription(msg='service {} tries to reserve more memory than the administrative limit'.format(service['name'])) raise InvalidApplicationDescription(msg='service {} tries to reserve more memory than the administrative limit'.format(service['name']))
......
...@@ -17,13 +17,25 @@ ...@@ -17,13 +17,25 @@
import json import json
import pytest import pytest
from collections import namedtuple
from zoe_lib import applications from zoe_lib import applications
ConfigMockup = namedtuple('ConfigMockup', ['max_core_limit', 'max_memory_limit'])
def fake_get_conf():
"""Mock-up for the config.get_conf() method."""
return ConfigMockup(16, 64)
class TestApplicationsMethods: class TestApplicationsMethods:
"""Application validation tests.""" """Application validation tests."""
@pytest.fixture(autouse=True)
def mock_config(self, monkeypatch):
monkeypatch.setattr('zoe_lib.config.get_conf', fake_get_conf)
def test_pass_for_zapp(self): def test_pass_for_zapp(self):
"""Test zapp validation code.""" """Test zapp validation code."""
zapp_fp = json.load(open('tests/zapp.json', 'r')) zapp_fp = json.load(open('tests/zapp.json', 'r'))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment