Example #1
0
 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)
Example #2
0
 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)
Example #3
0
 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) == {}
Example #4
0
 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}
Example #5
0
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}
Example #6
0
 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) == {}
Example #7
0
 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}