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 getOperatingSystemRelease(self): return OSCheck.get_os_version()