コード例 #1
0
    def setUp(self):
        self.db_name = self.new_random_workspace_name()

        self.couchdbmanager = CouchDbManager(CONF.getCouchURI())

        self.connector = self.couchdbmanager.createDb(self.db_name)
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)
コード例 #2
0
    def test_create_and_get_db(self):
        couch_manager = CouchDbManager(uri=CONF.getCouchURI())
        couch_manager.createDb(self.dbname)

        self.assertNotEquals(couch_manager.getDb(self.dbname), None,
                             "Db %s shouldn't be None" % self.dbname)

        server = Server(uri=CONF.getCouchURI())
        self.assertIn(self.dbname, server.all_dbs(),
                      "Db %s should be in the db list" % self.dbname)
コード例 #3
0
    def test_create_and_get_db(self):
        couch_manager = CouchDbManager(uri=CONF.getCouchURI())
        couch_manager.createDb(self.dbname)

        self.assertNotEquals(
            couch_manager.getDb(self.dbname),
            None,
            "Db %s shouldn't be None" % self.dbname)

        server = Server(uri=CONF.getCouchURI())
        self.assertIn(
            self.dbname,
            server.all_dbs(),
            "Db %s should be in the db list" % self.dbname)
コード例 #4
0
    def _showRepositoryConfigDialog(self):

        repoconfig_dialog = RepositoryConfigDialog(self, CONF.getCouchURI(),
                                                   CONF.getCouchIsReplicated(),
                                                   CONF.getCouchReplics(),
                                                   callback=None)
        result = repoconfig_dialog.exec_loop()
        if result == qt.QDialog.Accepted:
            repourl, isReplicated, replics = repoconfig_dialog.getData()
            api.devlog("repourl = %s" % repourl)
            wm = self._main_app.getWorkspaceManager()
            if not CouchDbManager.testCouch(repourl):
                self.showPopup("""
                Repository URL Not valid, check if
                service is available and that connection string is from
                the form: http[s]://hostname:port""")
                return

            CONF.setCouchUri(repourl)
            CONF.setCouchIsReplicated(isReplicated)
            CONF.setCouchReplics(replics)
            CONF.saveConfig()

            wm.closeWorkspace()
            wm.resource()
            wm.openWorkspace('untitled')

            mwin = self._main_app.getMainWindow()
            mwin.getWorkspaceTreeView().loadAllWorkspaces()
            mwin.getWorkspaceTreeView().setDefaultWorkspace()
コード例 #5
0
    def connect_to_couch(self, couch_uri, parent=None):
        """Tries to connect to a CouchDB on a specified Couch URI.
        Returns the success status of the operation, False for not successful,
        True for successful
        """
        if parent is None:
            parent = self.window

        if not CouchDbManager.testCouch(couch_uri):
            errorDialog(parent, "Could not connect to Faraday Server.",
                        ("Are you sure it is running and that you can "
                         "connect to it? \n Make sure your username and "
                         "password are still valid."))
            success = False
        elif couch_uri.startswith("https://"):
            if not checkSSL(couch_uri):
                errorDialog(self.window,
                            "The SSL certificate validation has failed")
            success = False
        else:
            CONF.setCouchUri(couch_uri)
            CONF.saveConfig()
            self.reload_workspaces()
            self.open_last_workspace()
            success = True
            self.lost_connection_dialog_raised = False
        return success
コード例 #6
0
    def handle_no_active_workspace(self):
        """If there's been a problem opening a workspace or for some reason
        we suddenly find our selves without one, force the user
        to select one if possible, or if not, to create one.
        """
        def change_flag(widget):
            self.workspace_dialogs_raised = not self.workspace_dialogs_raised

        if self.workspace_dialogs_raised:
            return False

        if not CouchDbManager.testCouch(CONF.getCouchURI()):
            # make sure it is not because we're not connected to Couch
            # there's another whole strategy for that.
            return False

        self.workspace_dialogs_raised = True

        available_workspaces = self.workspace_manager.getWorkspacesNames()
        workspace_model = self.ws_sidebar.workspace_model

        if available_workspaces:
            dialog = ForceChooseWorkspaceDialog(self.window, workspace_model,
                                                self.change_workspace)

        else:
            dialog = ForceNewWorkspaceDialog(self.window, self.createWorkspace,
                                             self.workspace_manager,
                                             self.ws_sidebar,
                                             self.exit_faraday)

        dialog.connect("destroy", change_flag)
        dialog.show_all()
コード例 #7
0
ファイル: mainwindow.py プロジェクト: m0sth8/faraday
    def _showRepositoryConfigDialog(self):

        repoconfig_dialog = RepositoryConfigDialog(self, CONF.getCouchURI(),
                                                   CONF.getCouchIsReplicated(),
                                                   CONF.getCouchReplics(),
                                                   callback=None)
        result = repoconfig_dialog.exec_loop()
        if result == qt.QDialog.Accepted:
            repourl, isReplicated, replics = repoconfig_dialog.getData()
            api.devlog("repourl = %s" % repourl)
            wm = self._main_app.getWorkspaceManager()
            if not CouchDbManager.testCouch(repourl):
                self.showPopup("""
                Repository URL Not valid, check if
                service is available and that connection string is from
                the form: http[s]://hostname:port""")
                return

            CONF.setCouchUri(repourl)
            CONF.setCouchIsReplicated(isReplicated)
            CONF.setCouchReplics(replics)
            CONF.saveConfig()

            wm.closeWorkspace()
            wm.resource()
            wm.openWorkspace('untitled')

            mwin = self._main_app.getMainWindow()
            mwin.getWorkspaceTreeView().loadAllWorkspaces()
            mwin.getWorkspaceTreeView().setDefaultWorkspace()
コード例 #8
0
    def do_activate(self):
        """If there's no window, create one and present it (show it to user).
        If there's a window, just present it. Also add the log handler
        and the notifier to the application"""

        # We only allow a single window and raise any existing ones
        if not self.window:
            # Windows are associated with the application
            # when the last one is closed the application shuts down
            self.window = AppWindow(self.sidebar,
                                    self.ws_sidebar,
                                    self.hosts_sidebar,
                                    self.terminal,
                                    self.console_log,
                                    self.statusbar,
                                    application=self,
                                    title="Faraday " + str(CONF.getVersion()))

        self.window.set_icon(self.icon)
        self.window.present()

        self.loghandler = GUIHandler()
        model.guiapi.setMainApp(self)
        addHandler(self.loghandler)
        self.loghandler.registerGUIOutput(self.window)

        notifier = model.log.getNotifier()
        notifier.widget = self.window
        model.guiapi.notification_center.registerWidget(self.window)

        if not CouchDbManager.testCouch(CONF.getCouchURI()):
            self.lost_db_connection(
                handle_connection_lost=self.handle_connection_lost,
                connect_to_a_different_couch=self.force_change_couch_url)
コード例 #9
0
ファイル: application.py プロジェクト: FreedomCoder/faraday
    def do_activate(self):
        """If there's no window, create one and present it (show it to user).
        If there's a window, just present it. Also add the log handler
        and the notifier to the application"""

        # We only allow a single window and raise any existing ones
        if not self.window:
            # Windows are associated with the application
            # when the last one is closed the application shuts down
            self.window = AppWindow(self.sidebar,
                                    self.ws_sidebar,
                                    self.hosts_sidebar,
                                    self.terminal,
                                    self.console_log,
                                    self.statusbar,
                                    application=self,
                                    title="Faraday " + str(CONF.getVersion()))

        self.window.set_icon(self.icon)
        self.window.present()

        self.loghandler = GUIHandler()
        model.guiapi.setMainApp(self)
        addHandler(self.loghandler)
        self.loghandler.registerGUIOutput(self.window)

        notifier = model.log.getNotifier()
        notifier.widget = self.window
        model.guiapi.notification_center.registerWidget(self.window)

        if not CouchDbManager.testCouch(CONF.getCouchURI()):
            self.lost_db_connection(
                handle_connection_lost=self.handle_connection_lost,
                connect_to_a_different_couch=self.force_change_couch_url)
コード例 #10
0
ファイル: application.py プロジェクト: FreedomCoder/faraday
    def connect_to_couch(self, couch_uri, parent=None):
        """Tries to connect to a CouchDB on a specified Couch URI.
        Returns the success status of the operation, False for not successful,
        True for successful
        """
        if parent is None:
            parent = self.window

        if not CouchDbManager.testCouch(couch_uri):
            errorDialog(parent, "Could not connect to Faraday Server.",
                        ("Are you sure it is running and that you can "
                         "connect to it? \n Make sure your username and "
                         "password are still valid."))
            success = False
        elif couch_uri.startswith("https://"):
            if not checkSSL(couch_uri):
                errorDialog(self.window,
                            "The SSL certificate validation has failed")
            success = False
        else:
            CONF.setCouchUri(couch_uri)
            CONF.saveConfig()
            self.reload_workspaces()
            self.open_last_workspace()
            success = True
            self.lost_connection_dialog_raised = False
        return success
コード例 #11
0
ファイル: application.py プロジェクト: FreedomCoder/faraday
    def handle_no_active_workspace(self):
        """If there's been a problem opening a workspace or for some reason
        we suddenly find our selves without one, force the user
        to select one if possible, or if not, to create one.
        """
        def change_flag(widget):
            self.workspace_dialogs_raised = not self.workspace_dialogs_raised

        if self.workspace_dialogs_raised:
            return False

        if not CouchDbManager.testCouch(CONF.getCouchURI()):
            # make sure it is not because we're not connected to Couch
            # there's another whole strategy for that.
            return False

        self.workspace_dialogs_raised = True

        available_workspaces = self.workspace_manager.getWorkspacesNames()
        workspace_model = self.ws_sidebar.workspace_model

        if available_workspaces:
            dialog = ForceChooseWorkspaceDialog(self.window,
                                                workspace_model,
                                                self.change_workspace)

        else:
            dialog = ForceNewWorkspaceDialog(self.window,
                                             self.createWorkspace,
                                             self.workspace_manager,
                                             self.ws_sidebar,
                                             self.exit_faraday)

        dialog.connect("destroy", change_flag)
        dialog.show_all()
コード例 #12
0
ファイル: mapper_integration.py プロジェクト: BwRy/faraday
    def setUp(self):
        self.db_name = self.new_random_workspace_name()

        self.couchdbmanager = CouchDbManager(CONF.getCouchURI())

        self.connector = self.couchdbmanager.createDb(self.db_name)
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)
コード例 #13
0
    def testThreadStops(self):
        changes_controller = ChangeController()
        mapper = mock()
        uri = CONF.getCouchURI()
        url = urlparse(uri)
        getLogger(self).debug("Setting user,pass %s %s" %
                              (url.username, url.password))
        self.cdbManager = CouchDbManager(uri=uri)

        dbCouchController = self.cdbManager.createDb('testWkspc')
        dbCouchController.saveDocument({
            '_id': 'testwkspc',
            'type': 'workspace'
        })

        changes_controller.watch(mapper, dbCouchController)
        self.assertTrue(changes_controller.isAlive())

        changes_controller.unwatch()
        self.assertFalse(changes_controller.isAlive())
コード例 #14
0
 def on_click_OK(self, button):
     """Defines what happens when user clicks OK button"""
     repourl = self.entry.get_text()
     if not CouchDbManager.testCouch(repourl):
         errorDialog(self, "The provided URL is not valid",
                     "Are you sure CouchDB is running?")
     elif repourl.startswith("https://"):
         if not checkSSL(repourl):
             errorDialog("The SSL certificate validation has failed")
     else:
         CONF.setCouchUri(repourl)
         CONF.saveConfig()
         self.reloadWorkspaces()
         self.destroy()
コード例 #15
0
ファイル: dialogs.py プロジェクト: NQIS/faraday
 def on_click_OK(self, button):
     """Defines what happens when user clicks OK button"""
     repourl = self.entry.get_text()
     if not CouchDbManager.testCouch(repourl):
         errorDialog(self, "The provided URL is not valid",
                     "Are you sure CouchDB is running?")
     elif repourl.startswith("https://"):
         if not checkSSL(repourl):
             errorDialog("The SSL certificate validation has failed")
     else:
         CONF.setCouchUri(repourl)
         CONF.saveConfig()
         self.reloadWorkspaces()
         self.destroy()
コード例 #16
0
ファイル: changes.py プロジェクト: BwRy/faraday
    def testThreadStops(self):
        changes_controller = ChangeController()
        mapper = mock()
        uri = CONF.getCouchURI()
        url = urlparse(uri)
        getLogger(self).debug(
            "Setting user,pass %s %s" % (url.username, url.password))
        self.cdbManager = CouchDbManager(uri=uri)
        
        dbCouchController = self.cdbManager.createDb('testWkspc')
        dbCouchController.saveDocument({'_id':'testwkspc',
                                    'type':'workspace' })

        changes_controller.watch(mapper, dbCouchController)
        self.assertTrue(changes_controller.isAlive())

        changes_controller.unwatch()
        self.assertFalse(changes_controller.isAlive())
コード例 #17
0
class ModelChanges(unittest.TestCase):
    def testThreadStops(self):
        changes_controller = ChangeController()
        mapper = mock()
        uri = CONF.getCouchURI()
        url = urlparse(uri)
        getLogger(self).debug("Setting user,pass %s %s" %
                              (url.username, url.password))
        self.cdbManager = CouchDbManager(uri=uri)

        dbCouchController = self.cdbManager.createDb('testWkspc')
        dbCouchController.saveDocument({
            '_id': 'testwkspc',
            'type': 'workspace'
        })

        changes_controller.watch(mapper, dbCouchController)
        self.assertTrue(changes_controller.isAlive())

        changes_controller.unwatch()
        self.assertFalse(changes_controller.isAlive())

    def testThreadStopsInFS(self):
        dbManagerClass = DbManager
        dbManagerClass._loadDbs = lambda x: None
        dbManager = DbManager()
        changes_controller = ChangeController()
        mapper = mock()
        fsController = dbManager.createDb('testWkspc', DBTYPE.FS)

        fsController.saveDocument({'_id': 'testwkspc', 'type': 'workspace'})

        changes_controller.watch(mapper, fsController)
        self.assertTrue(changes_controller.isAlive())

        changes_controller.unwatch()
        self.assertFalse(changes_controller.isAlive())
コード例 #18
0
ファイル: changes.py プロジェクト: BwRy/faraday
class ModelChanges(unittest.TestCase):
    def testThreadStops(self):
        changes_controller = ChangeController()
        mapper = mock()
        uri = CONF.getCouchURI()
        url = urlparse(uri)
        getLogger(self).debug(
            "Setting user,pass %s %s" % (url.username, url.password))
        self.cdbManager = CouchDbManager(uri=uri)
        
        dbCouchController = self.cdbManager.createDb('testWkspc')
        dbCouchController.saveDocument({'_id':'testwkspc',
                                    'type':'workspace' })

        changes_controller.watch(mapper, dbCouchController)
        self.assertTrue(changes_controller.isAlive())

        changes_controller.unwatch()
        self.assertFalse(changes_controller.isAlive())

    def testThreadStopsInFS(self):
        dbManagerClass = DbManager
        dbManagerClass._loadDbs = lambda x: None
        dbManager = DbManager()
        changes_controller = ChangeController()
        mapper = mock()
        fsController = dbManager.createDb('testWkspc', DBTYPE.FS)
        
        fsController.saveDocument({'_id':'testwkspc',
                                    'type':'workspace' })

        changes_controller.watch(mapper, fsController)
        self.assertTrue(changes_controller.isAlive())

        changes_controller.unwatch()
        self.assertFalse(changes_controller.isAlive())
コード例 #19
0
class MapperWithCouchDbManagerInegrationTest(unittest.TestCase):
    def setUp(self):
        self.db_name = self.new_random_workspace_name()

        self.couchdbmanager = CouchDbManager(CONF.getCouchURI())

        self.connector = self.couchdbmanager.createDb(self.db_name)
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)

    def new_random_workspace_name(self):
        return ("aworkspace" +
                "".join(random.sample([chr(i)
                                       for i in range(65, 90)], 10))).lower()

    def tearDown(self):
        self.couchdbmanager.deleteDb(self.db_name)
        time.sleep(3)

    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")

    def test_load_nonexistent_host_using_manager_find(self):
        self.assertEquals(self.connector.getDocument("1234"), None,
                          "Nonexistent host should return None document")

        self.assertEquals(self.mapper_manager.find("1234"), None,
                          "Nonexistent host should return None object")

    def test_load_nonexistent_host_using_mapper_find(self):
        self.assertEquals(self.connector.getDocument("1234"), None,
                          "Nonexistent host should return None document")

        self.assertEquals(
            self.mapper_manager.getMapper(Host.__name__).find("1234"), None,
            "Nonexistent host should return None object")

    def test_find_not_loaded_host(self):
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)

        #create a set of mappers, so we have a clean map
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)

        h = self.mapper_manager.find(host.getID())
        self.assertNotEquals(h, None, "Existent host shouldn't return None")

        self.assertEquals(h.getName(), "pepito", "Host name should be pepito")

        self.assertEquals(h.getOS(), "linux", "Host os should be linux")

    def test_host_create_and_delete(self):
        host = Host(name="coquito")
        self.mapper_manager.save(host)
        h_id = host.getID()

        self.assertNotEquals(self.mapper_manager.find(h_id), None,
                             "Host should be in the mapper")

        self.assertNotEquals(self.connector.getDocument(h_id), None,
                             "Host should be in the db")

        self.mapper_manager.remove(h_id)

        self.assertEquals(self.mapper_manager.find(h_id), None,
                          "Host shouldn't exist anymore in the mapper")

        self.assertEquals(self.connector.getDocument(h_id), None,
                          "Host shouldn't exist anymore in the db")

    def test_composite_host(self):
        # add host
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)
        # add inteface
        iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
        iface.setDescription("Some description")
        iface.setOwned(True)
        iface.addHostname("www.test.com")
        iface.setIPv4({
            "address": "192.168.10.168",
            "mask": "255.255.255.0",
            "gateway": "192.168.10.1",
            "DNS": "192.168.10.1"
        })
        iface.setPortsOpened(2)
        iface.setPortsClosed(3)
        iface.setPortsFiltered(4)
        host.addChild(iface)
        self.mapper_manager.save(iface)

        h = self.mapper_manager.find(host.getID())
        self.assertEquals(
            len(h.getAllInterfaces()), len(host.getAllInterfaces()),
            "Interfaces from original host should be equals to retrieved host's interfaces"
        )

        i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
        self.assertEquals(
            i.getID(), iface.getID(),
            "Interface's id' from original host should be equals to retrieved host's interface's id"
        )

    def test_load_not_loaded_composite_host(self):
        # add host
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)
        # add inteface
        iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
        iface.setDescription("Some description")
        iface.setOwned(True)
        iface.addHostname("www.test.com")
        iface.setIPv4({
            "address": "192.168.10.168",
            "mask": "255.255.255.0",
            "gateway": "192.168.10.1",
            "DNS": "192.168.10.1"
        })
        iface.setPortsOpened(2)
        iface.setPortsClosed(3)
        iface.setPortsFiltered(4)
        host.addChild(iface)
        self.mapper_manager.save(iface)

        #create a set of mappers, so we have a clean map
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)

        h = self.mapper_manager.find(host.getID())
        self.assertEquals(
            len(h.getAllInterfaces()), len(host.getAllInterfaces()),
            "Interfaces from original host should be equals to retrieved host's interfaces"
        )

        i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
        self.assertEquals(
            i.getID(), iface.getID(),
            "Interface's id' from original host should be equals to retrieved host's interface's id"
        )
コード例 #20
0
ファイル: mapper_integration.py プロジェクト: BwRy/faraday
class MapperWithCouchDbManagerInegrationTest(unittest.TestCase):
    def setUp(self):
        self.db_name = self.new_random_workspace_name()

        self.couchdbmanager = CouchDbManager(CONF.getCouchURI())

        self.connector = self.couchdbmanager.createDb(self.db_name)
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)

    def new_random_workspace_name(self):
        return ("aworkspace" + "".join(random.sample(
            [chr(i) for i in range(65, 90)], 10))).lower()

    def tearDown(self):
        self.couchdbmanager.deleteDb(self.db_name)
        time.sleep(3)

    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")

    def test_load_nonexistent_host_using_manager_find(self):
        self.assertEquals(
            self.connector.getDocument("1234"),
            None,
            "Nonexistent host should return None document")

        self.assertEquals(
            self.mapper_manager.find("1234"),
            None,
            "Nonexistent host should return None object")

    def test_load_nonexistent_host_using_mapper_find(self):
        self.assertEquals(
            self.connector.getDocument("1234"),
            None,
            "Nonexistent host should return None document")

        self.assertEquals(
            self.mapper_manager.getMapper(Host.__name__).find("1234"),
            None,
            "Nonexistent host should return None object")

    def test_find_not_loaded_host(self):
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)

        #create a set of mappers, so we have a clean map
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)

        h = self.mapper_manager.find(host.getID())
        self.assertNotEquals(
            h,
            None,
            "Existent host shouldn't return None")

        self.assertEquals(
            h.getName(),
            "pepito",
            "Host name should be pepito")

        self.assertEquals(
            h.getOS(),
            "linux",
            "Host os should be linux")

    def test_host_create_and_delete(self):
        host = Host(name="coquito")
        self.mapper_manager.save(host)
        h_id = host.getID()

        self.assertNotEquals(
            self.mapper_manager.find(h_id),
            None,
            "Host should be in the mapper")

        self.assertNotEquals(
            self.connector.getDocument(h_id),
            None,
            "Host should be in the db")

        self.mapper_manager.remove(h_id)

        self.assertEquals(
            self.mapper_manager.find(h_id),
            None,
            "Host shouldn't exist anymore in the mapper")

        self.assertEquals(
            self.connector.getDocument(h_id),
            None,
            "Host shouldn't exist anymore in the db")

    def test_composite_host(self):
        # add host
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)
        # add inteface
        iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
        iface.setDescription("Some description")
        iface.setOwned(True)
        iface.addHostname("www.test.com")
        iface.setIPv4({
            "address": "192.168.10.168",
            "mask": "255.255.255.0",
            "gateway": "192.168.10.1",
            "DNS": "192.168.10.1"
        })
        iface.setPortsOpened(2)
        iface.setPortsClosed(3)
        iface.setPortsFiltered(4)
        host.addChild(iface)
        self.mapper_manager.save(iface)

        h = self.mapper_manager.find(host.getID())
        self.assertEquals(
            len(h.getAllInterfaces()),
            len(host.getAllInterfaces()),
            "Interfaces from original host should be equals to retrieved host's interfaces")

        i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
        self.assertEquals(
            i.getID(),
            iface.getID(),
            "Interface's id' from original host should be equals to retrieved host's interface's id")

    def test_load_not_loaded_composite_host(self):
        # add host
        host = Host(name="pepito", os="linux")
        host.setDescription("Some description")
        host.setOwned(True)
        self.mapper_manager.save(host)
        # add inteface
        iface = Interface(name="192.168.10.168", mac="01:02:03:04:05:06")
        iface.setDescription("Some description")
        iface.setOwned(True)
        iface.addHostname("www.test.com")
        iface.setIPv4({
            "address": "192.168.10.168",
            "mask": "255.255.255.0",
            "gateway": "192.168.10.1",
            "DNS": "192.168.10.1"
        })
        iface.setPortsOpened(2)
        iface.setPortsClosed(3)
        iface.setPortsFiltered(4)
        host.addChild(iface)
        self.mapper_manager.save(iface)

        #create a set of mappers, so we have a clean map
        self.mapper_manager = MapperManager()
        self.mapper_manager.createMappers(self.connector)

        h = self.mapper_manager.find(host.getID())
        self.assertEquals(
            len(h.getAllInterfaces()),
            len(host.getAllInterfaces()),
            "Interfaces from original host should be equals to retrieved host's interfaces")

        i = self.mapper_manager.find(h.getAllInterfaces()[0].getID())
        self.assertEquals(
            i.getID(),
            iface.getID(),
            "Interface's id' from original host should be equals to retrieved host's interface's id")