def test_constant(self): testdict = {"Test1" : "Test", "Test2" : "Test", "Test3" : 3} cls = InfoGroup() for key, value in testdict.items(): cls.const(key, value) cls.generate() cls.update() outdict = cls.get() for key in testdict: self.assertEqual(testdict[key], outdict[key])
def test_files(self): resdict = {"File{}".format(x) : "File{}".format(x) for x in range(4)} cls = InfoGroup() for tkey in self.temp_files: _, tfname = self.temp_files[tkey] cls.addf(tkey, tfname) cls.generate() cls.update() outdict = cls.get() for i,tkey in enumerate(resdict): self.assertEqual(resdict[tkey], outdict[tkey])
def test_filesMatchConvert(self): resdict = {"File{}".format(x) : x for x in range(4)} match = r"File(\d+)" cls = InfoGroup() for tkey in self.temp_files: _, tfname = self.temp_files[tkey] cls.addf(tkey, tfname, match, int) cls.generate() cls.update() outdict = cls.get() for i,tkey in enumerate(resdict): self.assertEqual(resdict[tkey], outdict[tkey])
def test_commandsMatch(self): resdict = {"File{}".format(x) : "{}".format(x) for x in range(4)} match = r"File(\d+)" cls = InfoGroup() for tkey in self.temp_files: _, tfname = self.temp_files[tkey] cls.addc(tkey, "echo", "{}".format(tkey), match) cls.generate() cls.update() outdict = cls.get() for i,tkey in enumerate(resdict): self.assertEqual(resdict[tkey], outdict[tkey])
def test_empty(self): cls = InfoGroup() 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, [])
def test_anonymous(self): cls = InfoGroup(anonymous=True) self.assertEqual(cls.anonymous, True)
def test_extended(self): cls = InfoGroup(extended=True) self.assertEqual(cls.extended, True)
def test_named(self): cls = InfoGroup(name="Testname") self.assertEqual(cls.name, "Testname")