def test_idx_agentname_exists(self): """Testing function idx_agentname_exists.""" # Testing with known good value expected = True result = db_agentname.idx_agentname_exists( self.expected['idx_agentname']) self.assertEqual(result, expected) # Testing with known bad value expected = False result = db_agentname.idx_agentname_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_agentname = 1 idx_agent = 1 idx_device = 1 # Add agent name if db_agentname.idx_agentname_exists(idx_agentname) is False: # Generate a name add a record in the database record = AgentName( name=general.encode(self.reserved)) database = db.Database() database.add(record, 1019) # Add agent if db_agent.idx_agent_exists(idx_agent) is False: # Generate an Agent ID and add a record in the database record = Agent(id_agent=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)