diff options
author | Jan Synacek <jsynacek@redhat.com> | 2013-07-17 10:11:10 +0200 |
---|---|---|
committer | Jan Synacek <jsynacek@redhat.com> | 2013-07-17 10:11:10 +0200 |
commit | 17627a29921cb6faab3a771421717e904fe32725 (patch) | |
tree | c547154ebd6dd0ccec5d09cf460ef918f48c2f43 | |
parent | 5c3e1a6203e495bec37acd8c3731ca41377beb94 (diff) | |
download | openlmi-providers-17627a29921cb6faab3a771421717e904fe32725.tar.gz openlmi-providers-17627a29921cb6faab3a771421717e904fe32725.tar.xz openlmi-providers-17627a29921cb6faab3a771421717e904fe32725.zip |
LogicalFile: add tests for property checks
-rw-r--r-- | src/logicalfile/test/test_basic.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/src/logicalfile/test/test_basic.py b/src/logicalfile/test/test_basic.py index 4cc201b..fc4d336 100644 --- a/src/logicalfile/test/test_basic.py +++ b/src/logicalfile/test/test_basic.py @@ -320,5 +320,92 @@ class TestLogicalFile(LogicalFileTestBase): rmdir, '/cant/remove/me') + def _test_missing_or_wrong_properties(self, is_unixfile): + testfile = self.files['data'] + if is_unixfile: + prefix = 'LF' + clsname = 'LMI_UnixFile' + else: + prefix = '' + clsname = 'LMI_DataFile' + cop = pywbem.CIMInstanceName(classname=clsname, + namespace='root/cimv2', + keybindings={}) + + prop = 'CSCreationClassName' + self.assertRaisesRegexp(pywbem.CIMError, + '%s is empty' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = 'BadClass' + self.assertRaisesRegexp(pywbem.CIMError, + 'Wrong %s' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = self.SYSTEM_CLASS_NAME + + prop = 'CSName' + self.assertRaisesRegexp(pywbem.CIMError, + '%s is empty' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = 'BadClass' + self.assertRaisesRegexp(pywbem.CIMError, + 'Wrong %s' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = self.SYSTEM_NAME + + prop = prefix + 'CreationClassName' + self.assertRaisesRegexp(pywbem.CIMError, + '%s is empty' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = testfile['class'] + prop = prefix + 'Name' + cop.keybindings[prop] = self.files['dir']['path'] + if is_unixfile: + self.assertRaisesRegexp(pywbem.CIMError, + 'LFCreationClassName doesn\'t match', + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = testfile['path'] + + prop = 'FSCreationClassName' + self.assertRaisesRegexp(pywbem.CIMError, + '%s is empty' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = 'BadFS' + self.assertRaisesRegexp(pywbem.CIMError, + 'Wrong %s' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = 'LMI_LocalFileSystem' + + prop = 'FSName' + self.assertRaisesRegexp(pywbem.CIMError, + '%s is empty' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = 'BadFSName' + self.assertRaisesRegexp(pywbem.CIMError, + 'Wrong %s' % prop, + self.wbemconnection.GetInstance, + cop) + cop.keybindings[prop] = self.fsname + + # finally, test GetInstance on the correct object path + try: + self.wbemconnection.GetInstance(cop) + except pywbem.CIMError as pe: + self.fail(pe[1]) + + def test_unixfile_missing_or_wrong_properties(self): + self._test_missing_or_wrong_properties(True) + + def test_logicalfile_missing_or_wrong_properties(self): + self._test_missing_or_wrong_properties(False) + if __name__ == '__main__': unittest.main() |