示例#1
0
  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
示例#2
0
  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
示例#3
0
文件: system.py 项目: yesugei/ambari
 def os_version(self):
     """
 Example return value:
 "6.3" for "Centos 6.3"
 
 In case cannot detect --> Fail
 """
     return OSCheck.get_os_version()
示例#4
0
 def os_version(self):
   """
   Example return value:
   "6.3" for "Centos 6.3"
   
   In case cannot detect --> Fail
   """
   return OSCheck.get_os_version()
示例#5
0
    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')
示例#6
0
 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')
示例#7
0
 def getOperatingSystemRelease(self):
   return OSCheck.get_os_version()
示例#8
0
 def getOperatingSystemRelease(self):
   return OSCheck.get_os_version()