def test_diff_properties_fails(self): """ Test when diff_properties do not found a property """ expected = {"wrong_property": True} current = { "compression": { "description": "Set/get compression for a file or directory", "value": "N/A", }, "label": { "description": "Set/get label of device.", "value": "N/A" }, "ro": { "description": "Set/get read-only flag or subvolume", "value": "N/A", }, } with pytest.raises(Exception): btrfs._diff_properties(expected, current)
def test_diff_properties_fails(self): ''' Test when diff_properties do not found a property ''' expected = {'wrong_property': True} current = { 'compression': { 'description': 'Set/get compression for a file or directory', 'value': 'N/A', }, 'label': { 'description': 'Set/get label of device.', 'value': 'N/A', }, 'ro': { 'description': 'Set/get read-only flag or subvolume', 'value': 'N/A', }, } with pytest.raises(Exception): btrfs._diff_properties(expected, current)
def test_diff_properties_emty_na(self): """ Test when diff_properties is already disabled as N/A """ expected = {"ro": False} current = { "compression": { "description": "Set/get compression for a file or directory", "value": "N/A", }, "label": { "description": "Set/get label of device.", "value": "N/A" }, "ro": { "description": "Set/get read-only flag or subvolume", "value": "N/A", }, } assert btrfs._diff_properties(expected, current) == {}
def test_diff_properties_only_enable_ro(self): """ Test when diff_properties is half ready """ expected = {"ro": True, "label": "mylabel"} current = { "compression": { "description": "Set/get compression for a file or directory", "value": "N/A", }, "label": { "description": "Set/get label of device.", "value": "mylabel" }, "ro": { "description": "Set/get read-only flag or subvolume", "value": "N/A", }, } assert btrfs._diff_properties(expected, current) == {"ro": True}
def test_diff_properties_disable_ro(): """ Test when diff_properties enable one single property """ expected = {"ro": False} current = { "compression": { "description": "Set/get compression for a file or directory", "value": "N/A", }, "label": { "description": "Set/get label of device.", "value": "N/A" }, "ro": { "description": "Set/get read-only flag or subvolume", "value": True }, } assert btrfs._diff_properties(expected, current) == {"ro": False}
def test_diff_properties_emty_na(self): ''' Test when diff_properties is already disabled as N/A ''' expected = {'ro': False} current = { 'compression': { 'description': 'Set/get compression for a file or directory', 'value': 'N/A', }, 'label': { 'description': 'Set/get label of device.', 'value': 'N/A', }, 'ro': { 'description': 'Set/get read-only flag or subvolume', 'value': 'N/A', }, } assert btrfs._diff_properties(expected, current) == {}
def test_diff_properties_only_enable_ro(self): ''' Test when diff_properties is half ready ''' expected = {'ro': True, 'label': 'mylabel'} current = { 'compression': { 'description': 'Set/get compression for a file or directory', 'value': 'N/A', }, 'label': { 'description': 'Set/get label of device.', 'value': 'mylabel', }, 'ro': { 'description': 'Set/get read-only flag or subvolume', 'value': 'N/A', }, } assert btrfs._diff_properties(expected, current) == {'ro': True}