def test_invalidUpdate(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() self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(cls.userlist, userlist)
def test_validGenerate(self): userlist = [x for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=TestInfoGroup, subargs={"basepath": self.temp_dir}) cls.generate() self.assertEqual(len(cls._instances), 4) self.assertEqual(cls._data, {}) for inst in cls._instances: self.assertEqual(inst._instances, []) self.assertEqual(inst._data, {})
def test_validCreateInvalidClass(self): userlist = [x for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=unittest.TestCase, subargs={"basepath": self.temp_dir}) self.assertEqual(cls._instances, []) self.assertEqual(cls.subclass, unittest.TestCase)
def test_invalidCreate(self): userlist = [x + 100 for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=TestInfoGroup, subargs={"basepath": self.temp_dir}) self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(cls.userlist, userlist)
def test_empty(self): cls = ListInfoGroup() self.assertEqual(cls.name, None) self.assertEqual(cls.extended, False) self.assertEqual(cls.anonymous, False) self.assertEqual(cls.files, {}) self.assertEqual(cls.commands, {}) self.assertEqual(cls.constants, {}) self.assertEqual(cls._instances, []) self.assertEqual(cls.userlist, []) self.assertEqual(cls.subclass, None) self.assertEqual(cls.subargs, {})
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])
def test_subclassNone(self): cls = ListInfoGroup(subclass=None) self.assertEqual(cls.subclass, None)
def test_subclassString(self): cls = ListInfoGroup(subclass="abc") self.assertEqual(cls.subclass, None)
def test_userlistFilled(self): testl = ["a", "b", "c"] cls = ListInfoGroup(userlist=testl) self.assertEqual(cls.userlist, testl)
def test_userlistEmpty(self): cls = ListInfoGroup(userlist=[]) self.assertEqual(cls.userlist, [])
def test_userlistNone(self): cls = ListInfoGroup(userlist=None) self.assertEqual(cls.userlist, [])
def test_subargsDict(self): cls = ListInfoGroup(subargs={}) self.assertEqual(cls.subargs, {})
def test_named(self): cls = ListInfoGroup(name="Testname") self.assertEqual(cls.name, "Testname")
def test_validGenerateInvalidClass(self): userlist = [x for x in range(len(self.temp_files))] cls = ListInfoGroup(userlist=userlist, subclass=unittest.TestCase, subargs={"basepath": self.temp_dir}) self.assertRaises(TypeError, cls.generate)
def test_subclassClass(self): cls = ListInfoGroup(subclass=TestClass) self.assertEqual(cls.subclass, TestClass)
def test_subargsNone(self): cls = ListInfoGroup(subargs=None) self.assertEqual(cls.subargs, {})
def test_extended(self): cls = ListInfoGroup(extended=True) self.assertEqual(cls.extended, True)
def test_subargsBool(self): cls = ListInfoGroup(subargs=True) self.assertEqual(cls.subargs, {})
def test_anonymous(self): cls = ListInfoGroup(anonymous=True) self.assertEqual(cls.anonymous, True)