]> git.proxmox.com Git - ceph.git/blame - ceph/src/pybind/mgr/rook/rook-client-python/rook_client/tests/test_examples.py
import quincy beta 17.1.0
[ceph.git] / ceph / src / pybind / mgr / rook / rook-client-python / rook_client / tests / test_examples.py
CommitLineData
9f95a23c
TL
1from os.path import expanduser, dirname, realpath
2
3import yaml
4import pytest
5
6import rook_client
7from rook_client.cassandra.cluster import Cluster as CassandraCluster
8from rook_client.ceph.cephcluster import CephCluster
9from rook_client.ceph.cephfilesystem import CephFilesystem
10from rook_client.ceph.cephnfs import CephNFS
11from rook_client.ceph.cephobjectstore import CephObjectStore
20effc67 12from rook_client.ceph.cephblockpool import CephBlockPool
9f95a23c
TL
13
14
15def _load_example(crd_base, what):
16 with open(expanduser('{crd_base}/{what}').format(crd_base=crd_base, what=what)) as f:
17 return f.read()
18
19
20@pytest.mark.parametrize(
21 "strict,cls,filename",
22 [
23 (True, CephCluster, "ceph/cluster-external.yaml"),
9f95a23c
TL
24 (True, CephCluster, "ceph/cluster-on-pvc.yaml"),
25 (True, CephCluster, "ceph/cluster.yaml"),
26 (True, CephFilesystem, "ceph/filesystem-ec.yaml"),
27 (True, CephFilesystem, "ceph/filesystem-test.yaml"),
28 (True, CephFilesystem, "ceph/filesystem.yaml"),
29 (True, CephObjectStore, "ceph/object-ec.yaml"),
30 (True, CephObjectStore, "ceph/object-openshift.yaml"),
31 (True, CephObjectStore, "ceph/object-test.yaml"),
32 (True, CephObjectStore, "ceph/object.yaml"),
33 (True, CephNFS, "ceph/nfs.yaml"),
20effc67
TL
34 (True, CephBlockPool, "ceph/pool.yaml"),
35 (True, CephBlockPool, "ceph/pool-ec.yaml"),
36 (True, CephBlockPool, "ceph/pool-test.yaml"),
9f95a23c
TL
37
38 # schema invalid:
39 # (False, CassandraCluster, "cassandra/cluster.yaml"),
9f95a23c
TL
40 ],
41)
42def test_exact_match(strict, cls, filename, crd_base):
43 crds = yaml.safe_load_all(_load_example(crd_base, filename))
44 rook_client.STRICT = strict
45 [crd] = [e for e in crds if e.get('kind', '') == cls.__name__]
46
47 c = cls.from_json(crd)
48 assert crd == c.to_json()
49
50
51
52