def test_get_list(self): """ Test retrieving a list of eotps """ for data in test_data: result = Eotp.get_list(filters=data.items(), pattern=data["pattern"]) self.assertIsInstance(result, type([])) for eotp, codes in zip(result, data["expected"]): self.assertIsInstance(eotp, Eotp) self.assertEqual(eotp.code, codes[0]) if len(codes) == 2: self.assertEqual(eotp.cost_center.code, codes[1]) else: self.assertIsNone(eotp.cost_center)
def test_get_dict(self): """ Test retrieving a dict of eotps """ for data in test_data: result = Eotp.get_dict(filters=data.items(), pattern=data["pattern"]) self.assertIsInstance(result, type({})) for key_code, codes in izip(sorted(result), data["expected"]): eotp = result[key_code] self.assertIsInstance(eotp, Eotp) self.assertEqual(eotp.code, codes[0]) if len(codes) == 2: self.assertEqual(eotp.cost_center.code, codes[1]) else: self.assertIsNone(eotp.cost_center) self.assertEqual(key_code, codes[0])