ref: foo
""".strip()
)
+
+
+def test_apply_invalid_res(tmodule):
+ result = tmodule.apply_resources(
+ """
+resource_type: ceph.smb.cluster
+cluster_id: ""
+auth_mode: doop
+"""
+ )
+ assert not result.success
+ assert 'doop' in result.to_simplified()['results'][0]['msg']
+
+
+def test_show_all(tmodule):
+ _example_cfg_1(tmodule)
+ out = tmodule.show()
+ assert 'resources' in out
+ res = out['resources']
+ assert len(res) == 4
+ assert {r['resource_type'] for r in res} == {
+ 'ceph.smb.cluster',
+ 'ceph.smb.share',
+ 'ceph.smb.join.auth',
+ }
+
+
+def test_show_shares(tmodule):
+ _example_cfg_1(tmodule)
+ out = tmodule.show(['ceph.smb.share'])
+ assert 'resources' in out
+ res = out['resources']
+ assert len(res) == 2
+ assert {r['resource_type'] for r in res} == {
+ 'ceph.smb.share',
+ }
+
+
+def test_show_shares_in_cluster(tmodule):
+ _example_cfg_1(tmodule)
+ out = tmodule.show(['ceph.smb.share.foo'])
+ assert 'resources' in out
+ res = out['resources']
+ assert len(res) == 2
+ assert {r['resource_type'] for r in res} == {
+ 'ceph.smb.share',
+ }
+ assert {r['cluster_id'] for r in res} == {'foo'}
+
+
+def test_show_specific_share(tmodule):
+ _example_cfg_1(tmodule)
+ out = tmodule.show(['ceph.smb.share.foo.s1'])
+ assert 'resources' not in out
+ assert out['resource_type'] == 'ceph.smb.share'
+ assert out['cluster_id'] == 'foo'
+ assert out['share_id'] == 's1'
+
+
+def test_show_nomatches(tmodule):
+ _example_cfg_1(tmodule)
+ out = tmodule.show(['ceph.smb.share.foo.whoops'])
+ assert 'resources' in out
+ assert out['resources'] == []
+
+
+def test_show_invalid_input(tmodule):
+ _example_cfg_1(tmodule)
+ with pytest.raises(smb.cli.InvalidInputValue):
+ tmodule.show(['ceph.smb.export'])