def test_idx_agent_exists(self): """Testing function idx_agent_exists.""" # Testing with known good value expected = True result = db_agent.idx_agent_exists(self.expected['idx_agent']) self.assertEqual(result, expected) # Testing with known bad value expected = False result = db_agent.idx_agent_exists(None) self.assertEqual(result, expected)
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)