test_aci.py 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
"""Tests for the ACI Manifest module."""
import nrm
import nrm.aci
import pytest
import json


@pytest.fixture
def manifest_base_data():
    data = '''{
    "acKind": "ImageManifest",
    "acVersion": "0.6.0",
    "name": "test",
    "app":
        {
        "isolators": []
        }
}'''
    return json.loads(data)


def test_manifest_disabled_perfwrapper(manifest_base_data):
    """Ensure we can check if a feature is disabled."""
    manifest = nrm.aci.ImageManifest()
    isolator_text = '''{
    "name": "argo/perfwrapper",
    "value": {
        "enabled": "0"
    }
}'''
    isolator = json.loads(isolator_text)
    data = manifest_base_data
    data["app"]["isolators"] = [isolator]
    assert manifest.load_dict(data)
    assert not manifest.is_feature_enabled("perfwrapper")


def test_enabled_feature(manifest_base_data):
    """Ensure we can check if a feature is enabled without enabled in it."""
    manifest = nrm.aci.ImageManifest()
    isolator_text = '''{
    "name": "argo/perfwrapper",
    "value": {}
}'''
    isolator = json.loads(isolator_text)
    data = manifest_base_data
    data["app"]["isolators"] = [isolator]
    assert manifest.load_dict(data)
    assert manifest.is_feature_enabled("perfwrapper")