def test_invalidUpdate(self): searchpath = os.path.join(self.temp_dir, "*abc") cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=TestPathMatchInfoGroup, subargs={"searchpath": self.temp_dir}) cls.generate() cls.update() self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {}) self.assertEqual(cls.searchpath, searchpath)
def test_validUpdateInvalidClass(self): searchpath = os.path.join(self.temp_dir, "*") cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=unittest.TestCase, subargs={"searchpath": self.temp_dir}) try: cls.generate() except: pass cls.update() self.assertEqual(cls._instances, []) self.assertEqual(cls._data, {})
def test_validGet(self): searchpath = os.path.join(self.temp_dir, "*") cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=TestPathMatchInfoGroup, subargs={"searchpath": 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])