aboutsummaryrefslogtreecommitdiffstats
path: root/moon_cache/tests/unit_python/api/test_attributes.py
blob: 13bfc637bca2afaef496bd21bf03498ea3dda4e3 (plain)
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
# Software Name: MOON

# Version: 5.4

# SPDX-FileCopyrightText: Copyright (c) 2018-2020 Orange and its contributors
# SPDX-License-Identifier: Apache-2.0

# This software is distributed under the 'Apache License 2.0',
# the text of which is available at 'http://www.apache.org/licenses/LICENSE-2.0.txt'
# or see the "LICENSE" file for more details.



def test_get_attribute_success(configuration):
    from moon_cache import cache
    cache_obj = cache.Cache.getInstance(manager_url=configuration["management"]["url"])
    name = 'mode'
    value = "run"
    cache_obj.set_attribute(name=name)
    assert cache_obj.attributes
    assert cache_obj.attributes.get(name)
    assert cache_obj.attributes.get(name) == "build"
    cache_obj.set_attribute(name=name, value=value)
    assert cache_obj.attributes
    assert cache_obj.attributes.get(name)
    # Note: it is the same value because the cache systematically request the Manager
    assert cache_obj.attributes.get(name) == "build"


def test_get_attribute_unknown(configuration):
    from moon_cache import cache
    cache_obj = cache.Cache.getInstance(manager_url=configuration["management"]["url"])
    name = 'test'
    assert cache_obj.attributes
    assert not cache_obj.attributes.get(name)