def test_invalidGet(self): userlist = [x + 100 for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=TestInfoGroup, subargs={"basepath": self.temp_dir}) self.assertRaises(IndexError, cls.generate) cls.update() outdict = cls.get() self.assertEqual(outdict, {}) self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(cls.userlist, userlist)
def test_validGetInvalidClass(self): userlist = [x for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=unittest.TestCase, subargs={"basepath": self.temp_dir}) try: cls.generate() except: pass cls.update() outdict = cls.get() self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(outdict, {})
def test_validGet(self): userlist = [x for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=TestInfoGroup, subargs={"basepath": self.temp_dir}) cls.generate() cls.update() outdict = cls.get() self.assertEqual(cls._data, {}) for inst in cls._instances: self.assertEqual(inst._instances, []) self.assertNotEqual(inst._data, {}) for i, key in enumerate(self.temp_files.keys()): for subkey in outdict[key]: self.assertEqual(key, subkey) self.assertEqual(key, outdict[key][subkey])