class TestGetIDXDepartment(unittest.TestCase): """Checks all functions and methods.""" ######################################################################### # General object setup ######################################################################### # Setup database based on the config database = unittest_setup_db.TestData() # Define expected values expected = {} expected['idx_department'] = database.idx_department() expected['name'] = database.department_name() expected['code'] = database.department_code() expected['enabled'] = True expected['exists'] = True # Retrieve data good_agent = db_department.GetIDXDepartment(expected['idx_department']) def test_init_(self): """Testing method init.""" # Test with non existent AgentIDX record = db_department.GetIDXDepartment(-1) self.assertEqual(record.exists(), False) def test_idx_department(self): """Testing method idx_department.""" # Testing with known good value result = self.good_agent.idx_department() self.assertEqual(result, self.expected['idx_department']) # Testing with known bad value expected = ('bogus') result = self.good_agent.idx_department() self.assertNotEqual(result, expected) def test_name(self): """Testing method name.""" # Testing with known good value result = self.good_agent.name() self.assertEqual(result, self.expected['name']) # Testing with known bad value expected = ('bogus') result = self.good_agent.name() self.assertNotEqual(result, expected) def test_code(self): """Testing method code.""" # Testing with known good value result = self.good_agent.code() self.assertEqual(result, self.expected['code']) # Testing with known bad value expected = ('bogus') result = self.good_agent.code() self.assertNotEqual(result, expected) def test_exists(self): """Testing method exists.""" # Testing with known good value result = self.good_agent.exists() self.assertEqual(result, True) def test_enabled(self): """Testing method enabled.""" # Testing with known good value result = self.good_agent.enabled() self.assertEqual(result, self.expected['enabled']) # Testing with known bad value expected = ('bogus') result = self.good_agent.enabled() self.assertNotEqual(result, expected) def test_everything(self): """Testing method everything.""" # Testing with known good value result = self.good_agent.everything() for key, _ in self.expected.items(): self.assertEqual(result[key], self.expected[key]) # Test the number and names of keys keys = ['idx_department', 'code', 'name', 'enabled', 'exists'] self.assertEqual(len(result), len(keys)) for key in keys: self.assertEqual(key in result, True)
def test_init_(self): """Testing method init.""" # Test with non existent AgentIDX record = db_department.GetIDXDepartment(-1) self.assertEqual(record.exists(), False)
class TestGetIDXDepartment(unittest.TestCase): """Checks all functions and methods.""" ######################################################################### # General object setup ######################################################################### # Setup database expected = unittest_db.setup_db_department() # Retrieve data good_agent = db_department.GetIDXDepartment(expected['idx_department']) def test_init_(self): """Testing method init.""" # Test with non existent AgentIDX record = db_department.GetIDXDepartment(-1) self.assertEqual(record.exists(), False) def test_idx_department(self): """Testing method idx_department.""" # Testing with known good value result = self.good_agent.idx_department() self.assertEqual(result, self.expected['idx_department']) # Testing with known bad value expected = ('bogus') result = self.good_agent.idx_department() self.assertNotEqual(result, expected) def test_name(self): """Testing method name.""" # Testing with known good value result = self.good_agent.name() self.assertEqual(result, self.expected['name']) # Testing with known bad value expected = ('bogus') result = self.good_agent.name() self.assertNotEqual(result, expected) def test_code(self): """Testing method code.""" # Testing with known good value result = self.good_agent.code() self.assertEqual(result, self.expected['code']) # Testing with known bad value expected = ('bogus') result = self.good_agent.code() self.assertNotEqual(result, expected) def test_exists(self): """Testing method exists.""" # Testing with known good value result = self.good_agent.exists() self.assertEqual(result, True) def test_enabled(self): """Testing method enabled.""" # Testing with known good value result = self.good_agent.enabled() self.assertEqual(result, self.expected['enabled']) # Testing with known bad value expected = ('bogus') result = self.good_agent.enabled() self.assertNotEqual(result, expected)