當前位置: 首頁>>代碼示例>>Python>>正文


Python Host.getName方法代碼示例

本文整理匯總了Python中model.hosts.Host.getName方法的典型用法代碼示例。如果您正苦於以下問題:Python Host.getName方法的具體用法?Python Host.getName怎麽用?Python Host.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在model.hosts.Host的用法示例。


在下文中一共展示了Host.getName方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: testGetHost

# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getName [as 別名]
    def testGetHost(self):
        host = Host("coquito")

        mappersManager = self.createMapperMock()
        objectMapper = mock()
        when(mappersManager).getMapper(host.__class__.__name__).thenReturn(objectMapper)
        when(objectMapper).find(host.getName()).thenReturn(host)

        model_controller = controller.ModelController(mock(), mappersManager) 

        host_obt =  model_controller.getHost('coquito')

        verify(objectMapper).find(host.getName())
        verify(mappersManager).getMapper(host.__class__.__name__)

        self.assertEqual(host, host_obt)
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:18,代碼來源:dont_run_but_update_model_controller.py

示例2: testDelRemovesObjectFromTrie

# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getName [as 別名]
    def testDelRemovesObjectFromTrie(self): 
        host = Host("coquito")

        mappersManager = self.createMapperMock()
        objectMapper = mock()
        triemock = mock()
        when(mappersManager).getMapper(host.class_signature).thenReturn(objectMapper)
        when(mappersManager).find(host.getID()).thenReturn(host)
        when(triemock).addWord(host.getName()).thenReturn(True)

        model_controller = controller.ModelController(mock(), mappersManager) 
        model_controller.treeWordsTries = triemock
        model_controller.delHostSYNC(host.getID()) 
        verify(mappersManager).remove(host.getID())

        verify(triemock).removeWord(host.getName()) 
開發者ID:BecomingMore,項目名稱:faraday,代碼行數:18,代碼來源:dont_run_but_update_model_controller.py

示例3: test_host_serialization

# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getName [as 別名]
 def test_host_serialization(self):
     host = Host(name="pepito", os="linux")
     host.setDescription("Some description")
     host.setOwned(True)
     hserialized = self.hmapper.serialize(host)
     # if serialization fails, returns None
     self.assertNotEqual(
         hserialized,
         None,
         "Serialized host shouldn't be None")
     # we check the host attributes
     self.assertEquals(
         hserialized.get("_id"),
         host.getID(),
         "Serialized ID is not the same as Host ID")
     self.assertEquals(
         hserialized.get("name"),
         host.getName(),
         "Serialized name is not the same as Host name")
     self.assertEquals(
         hserialized.get("os"),
         host.getOS(),
         "Serialized OS is not the same as Host OS")
     self.assertEquals(
         hserialized.get("description"),
         host.getDescription(),
         "Serialized description is not the same as Host description")
     self.assertEquals(
         hserialized.get("owned"),
         host.isOwned(),
         "Serialized owned flag is not the same as Host owned flag")
開發者ID:BwRy,項目名稱:faraday,代碼行數:33,代碼來源:mapper.py

示例4: testAddSavesObjectNameInTrie

# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getName [as 別名]
    def testAddSavesObjectNameInTrie(self):
        host = Host('coco')

        mappersManager = self.createMapperMock()
        objectMapper = mock()
        triemock = mock()

        when(mappersManager).getMapper(host).thenReturn(objectMapper)
        when(objectMapper).saveObject(host).thenReturn(True)
        when(triemock).addWord(host.getName()).thenReturn(True)

        model_controller = controller.ModelController(mock(), mappersManager)
        model_controller.treeWordsTries = triemock

        model_controller.addHostSYNC(host)

        verify(mappersManager).getMapper(host)
        verify(objectMapper).saveObject(host)
        verify(triemock).addWord(host.getName())
開發者ID:BwRy,項目名稱:faraday,代碼行數:21,代碼來源:model_controller.py

示例5: test_host_saving

# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getName [as 別名]
    def test_host_saving(self):
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)

        self.assertNotEquals(
            self.connector.getDocument(host.getID()),
            None,
            "Document shouldn't be None")

        self.assertEquals(
            self.connector.getDocument(host.getID()).get("name"),
            host.getName(),
            "Document should have the same host name")
開發者ID:BwRy,項目名稱:faraday,代碼行數:17,代碼來源:mapper_integration.py

示例6: testEditHostSyncGetsMapperDispatchedSYNC

# 需要導入模塊: from model.hosts import Host [as 別名]
# 或者: from model.hosts.Host import getName [as 別名]
    def testEditHostSyncGetsMapperDispatchedSYNC(self):
        host = Host("coquito")

        mappersManager = self.createMapperMock()
        objectMapper = mock()
        triemock = mock()
        when(mappersManager).find(host.getID()).thenReturn(host)
        when(mappersManager).saveObject(host).thenReturn(True)

        model_controller = controller.ModelController(mock(), mappersManager) 

        model_controller.editHostSYNC(host.getID(), 'new_name', 'new_desc', 'new_os', True)

        verify(mappersManager).saveObject(host) 
        verify(mappersManager).find(host.getID())

        self.assertEquals(host.getName(), 'new_name', "Name not updated")
        self.assertEquals(host.getDescription(), 'new_desc', "Description not updated")
        self.assertEquals(host.getOS(), 'new_os', "OS not updated")
        self.assertEquals(host.isOwned(), True, "Owned status not updated")
開發者ID:BwRy,項目名稱:faraday,代碼行數:22,代碼來源:model_controller.py


注:本文中的model.hosts.Host.getName方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。