]>
Commit | Line | Data |
---|---|---|
9f95a23c TL |
1 | from os.path import expanduser, dirname, realpath |
2 | ||
3 | import yaml | |
4 | import pytest | |
5 | ||
6 | import rook_client | |
7 | from rook_client.cassandra.cluster import Cluster as CassandraCluster | |
8 | from rook_client.ceph.cephcluster import CephCluster | |
9 | from rook_client.ceph.cephfilesystem import CephFilesystem | |
10 | from rook_client.ceph.cephnfs import CephNFS | |
11 | from rook_client.ceph.cephobjectstore import CephObjectStore | |
20effc67 | 12 | from rook_client.ceph.cephblockpool import CephBlockPool |
9f95a23c TL |
13 | |
14 | ||
15 | def _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 | ) | |
42 | def 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 |