def __init__(self): """Method initializing the class.""" # Setup database variables self.url = URL self.engine = TEST_ENGINE # Get configuration self.config = configuration.Config() # Validate the configuration unittest_setup.ready() # Validate the database self.validate()
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 test_get_all_agents(self): """Testing function get_all_agents.""" # Testing with known good value result = db_agent.get_all_agents() self.assertEqual(isinstance(result, list), True) self.assertEqual(result[0]['idx_agent'], self.expected['idx_agent']) self.assertEqual(result[0]['exists'], self.expected['exists']) self.assertEqual(result[0]['enabled'], self.expected['enabled']) self.assertEqual(result[0]['idx_agentname'], self.expected['idx_agentname']) if __name__ == '__main__': # Test the environment variables unittest_setup.ready() # Do the unit test unittest.main()