Ejemplo n.º 1
0
    def test_idx_device_exists(self):
        """Testing function idx_exists."""
        # Test known working value
        result = db_device.idx_device_exists(self.expected['idx_device'])
        self.assertEqual(result, True)

        # Test known false value
        result = db_device.idx_device_exists(-1)
        self.assertEqual(result, False)
Ejemplo n.º 2
0
    def _insert_agent_device(self):
        """Insert first agent and device in the database.

        Args:
            None

        Returns:
            None

        """
        # Initialize key variables
        idx_agent = 1
        idx_device = 1

        # Add agent
        if db_agent.idx_agent_exists(idx_agent) is False:
            # Generate a UID and add a record in the database
            record = Agent(id_agent=general.encode(self.reserved),
                           name=general.encode(self.reserved))
            database = db.Database()
            database.add(record, 1109)

        # Add device
        if db_device.idx_device_exists(idx_device) is False:
            record = Device(description=general.encode(self.reserved),
                            devicename=general.encode(self.reserved))
            database = db.Database()
            database.add(record, 1106)

        # Add to Agent / Device table
        if db_deviceagent.device_agent_exists(idx_device, idx_agent) is False:
            record = DeviceAgent(idx_device=idx_device, idx_agent=idx_agent)
            database = db.Database()
            database.add(record, 1107)