Пример #1
0
def test_values():
    n = from_dict(simple_data)
    assert n["a"].value == 3

    assert n["b"].value == "four five"
    assert n["b"].string_value == "four five"

    assert n["c"].value == "9 15"
    assert n["c"].string_value == "9 15"

    assert n["d"]["e"].value == 9.7
Пример #2
0
        "message": "Error while reconciling 4.2.0-0.ci-2019-08-04-183142: the cluster operator console has not yet successfully rolled out"
      },
      {
        "type": "RetrievedUpdates",
        "status": "False",
        "lastTransitionTime": "2019-08-04T23:17:08Z",
        "reason": "RemoteFailed",
        "message": "Unable to retrieve available updates: currently installed version 4.2.0-0.ci-2019-08-04-183142 not found in the stable-4.2 channel"
      }
    ],
    "availableUpdates": null
  }
}
''')

d = from_dict(DATA)


def test_values():
    assert d.status.conditions.status.values == [
        "True", "True", "False", "False"
    ]


def test_where():
    assert len(d.status.conditions.where("type", "Progressing")) == 1

    res = d.status.conditions.where(
        q("type", "Progressing") | q("status", "True"))
    assert len(res) == 3
Пример #3
0
        "message": "Error while reconciling 4.2.0-0.ci-2019-08-04-183142: the cluster operator console has not yet successfully rolled out"
      },
      {
        "type": "RetrievedUpdates",
        "status": "False",
        "lastTransitionTime": "2019-08-04T23:17:08Z",
        "reason": "RemoteFailed",
        "message": "Unable to retrieve available updates: currently installed version 4.2.0-0.ci-2019-08-04-183142 not found in the stable-4.2 channel"
      }
    ],
    "availableUpdates": null
  }
}
''')

conf = from_dict(DATA)


def test_simple():
    res = conf.status.conditions.choose(lambda c: (c.type, c.reason))
    assert "type" in res
    assert "reason" in res
    assert "status" not in res


def test_ancestor():
    res = conf.status.conditions.choose(
        lambda c: (c.type, c.reason, c.upto("status").desired.version))
    assert "type" in res
    assert "reason" in res
    assert "version" in res
Пример #4
0
def _load(path):
    with open(path) as f:
        doc = yaml.load(f, Loader=Loader)
        return from_dict(doc)
Пример #5
0
def test_from_dict():
    n = from_dict(simple_data)
    assert n
    assert len(n) == 4
Пример #6
0
def _load(path):
    with open(path) as f:
        for doc in yaml.load_all(f, Loader=Loader):
            yield from_dict(doc, src=path)