def test_get_os_version(self, mock_linux_distribution): # 1 - Any system mock_linux_distribution.return_value = ('', '123.45', '') result = OSCheck.get_os_version() self.assertEquals(result, '123.45') # 2 - Negative case mock_linux_distribution.return_value = ('ssss', '', 'ddddd') try: result = OSCheck.get_os_version() self.fail("Should throw exception in OSCheck.get_os_version()") except Exception as e: # Expected self.assertEquals("Cannot detect os version. Exiting...", str(e)) pass
def os_version(self): """ Example return value: "6.3" for "Centos 6.3" In case cannot detect --> Fail """ return OSCheck.get_os_version()
def test_aliases(self, mock_linux_distribution): OSConst.OS_TYPE_ALIASES['qwerty_os123'] = 'aliased_os5' OSConst.OS_FAMILY_COLLECTION.append({ 'name': 'aliased_os_family', 'os_list': ["aliased_os"] }) mock_linux_distribution.return_value = ('qwerty_os', '123.45.67', '') self.assertEquals(OSCheck.get_os_type(), 'aliased_os') self.assertEquals(OSCheck.get_os_major_version(), '5') self.assertEquals(OSCheck.get_os_version(), '5.45.67') self.assertEquals(OSCheck.get_os_family(), 'aliased_os_family')
def getOperatingSystemRelease(self): return OSCheck.get_os_version()