Example #1
0
 def test_get_libvirt_enum_string_underscores(self, libvirt_mock):
     """
     Make sure the libvirt enum value to string works reliably and items
     with an underscore aren't confused with sub prefixes.
     """
     assert libvirt_events._get_libvirt_enum_string("VIR_PREFIX_",
                                                    1) == "bar foo"
Example #2
0
    def test_get_libvirt_enum_string_subprefix(self, libvirt_mock):
        '''
        Make sure the libvirt enum value to string works reliably with
        elements with a sub prefix, eg VIR_PREFIX_SUB_* in this case.
        '''
        # Test case with a sub prefix

        assert libvirt_events._get_libvirt_enum_string('VIR_PREFIX_', 2) == 'two'
Example #3
0
def test_get_libvirt_enum_string_subprefix(mock_libvirt):
    """
    Make sure the libvirt enum value to string works reliably with
    elements with a sub prefix, eg VIR_PREFIX_SUB_* in this case.
    """
    # Test case with a sub prefix
    mock_libvirt.VIR_PREFIX_NONE = 0
    mock_libvirt.VIR_PREFIX_ONE = 1
    mock_libvirt.VIR_PREFIX_TWO = 2
    mock_libvirt.VIR_PREFIX_SUB_FOO = 0
    mock_libvirt.VIR_PREFIX_SUB_BAR = 1
    mock_libvirt.VIR_PREFIX_SUB_FOOBAR = 2

    assert libvirt_events._get_libvirt_enum_string("VIR_PREFIX_", 2) == "two"
Example #4
0
 def test_get_libvirt_enum_string_underscores(self, libvirt_mock):
     '''
     Make sure the libvirt enum value to string works reliably and items
     with an underscore aren't confused with sub prefixes.
     '''
     assert libvirt_events._get_libvirt_enum_string('VIR_PREFIX_', 1) == 'foo bar'