def test_set_property_dataset_validation_unhappy(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert False, 'This should not have been called' with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS() with pytest.raises(ValidationError): zfs.set_property('ta#nk/test', 'compression', 'lz4')
def test_set_property_poolname_invalid_nometa_unhappy(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert False, 'This should not have been called' with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS() with pytest.raises(ValidationError) as excinfo: zfs.set_property(' ', 'compression', 'lz4') assert 'malformed' in str(excinfo.value)
def test_set_property_meta_ns_happy(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert dataset == 'tank/test' assert key == 'testns:testprop' assert value == 'testval' assert is_metadata with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS(metadata_namespace='testns') zfs.set_property('tank/test', 'testprop', 'testval', metadata=True)
def test_set_property_nometa_happy(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert dataset == 'tank/test' assert key == 'compression' assert value == 'lz4' assert not is_metadata with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS() zfs.set_property('tank/test', 'compression', 'lz4')
def test_set_property_all_meta_happy(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert 'tank/test' == dataset assert 'testns:all' == key assert 'test' == value assert is_metadata with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS(metadata_namespace='testns') zfs.set_property('tank/test', 'all', 'test', metadata=True)
def test_set_property_meta_ns_noflag_inalid(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert False, 'This should not have been called' with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS(metadata_namespace='testns') with pytest.raises(ValidationError): zfs.set_property('tank/test', 'testns:testprop', 'testval', metadata=False)
def test_set_property_meta_nooverwrite_invalidns_unhappy(self): ''' Tests the validation of the metadata namespace, coming from the ctor. ''' def mock_set_property(myself, dataset, key, value, is_metadata): assert False, 'This should not have been called' with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS(metadata_namespace=' ') with pytest.raises(ValidationError) as excinfo: zfs.set_property('tank/test', 'test', 'test', metadata=True) assert 'not match' in str(excinfo.value)
def test_set_property_nometa_nons_unhappy(self): def mock_set_property(myself, dataset, key, value, is_metadata): assert False, 'This should not have been called' with patch.object(ZFS, '_set_property', new=mock_set_property): zfs = ZFS() assert zfs.metadata_namespace is None with pytest.raises(ValidationError) as excinfo: zfs.set_property('tank/test', 'testprop', 'testval', metadata=True) assert 'no metadata namespace set' in str(excinfo.value)
def test_set_property_all_nometa_unhappy(self): zfs = ZFS() with pytest.raises(ValidationError) as excinfo: zfs.set_property('tank/test', 'all', 'test') assert 'valid property name' in str(excinfo.value)
def test_set_property_notimplemented(self): zfs = ZFS() with pytest.raises(NotImplementedError): zfs.set_property('tank/test1', 'compression', 'lz4')