Ejemplo n.º 1
0
 def test_invalidGenerate(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()
     self.assertEqual(cls._instances, [])
     self.assertEqual(cls._data, {})
     self.assertEqual(cls.searchpath, searchpath)
Ejemplo n.º 2
0
 def test_validGenerate(self):
     searchpath = os.path.join(self.temp_dir, "*")
     cls = PathMatchInfoGroup(searchpath=searchpath, match=r".*/(\d).*", subclass=TestPathMatchInfoGroup, subargs={"searchpath": self.temp_dir})
     cls.generate()
     self.assertNotEqual(cls._instances, [])
     self.assertEqual(len(cls._instances), 4)
     self.assertEqual(cls._data, {})
     for inst in cls._instances:
         self.assertEqual(inst._instances, [])
         self.assertEqual(inst._data, {})
Ejemplo n.º 3
0
 def test_validGenerateInvalidClass(self):
     searchpath = os.path.join(self.temp_dir, "*")
     cls = PathMatchInfoGroup(searchpath=searchpath,
                              match=r".*/(\d).*",
                              subclass=unittest.TestCase,
                              subargs={"searchpath": self.temp_dir})
     self.assertRaises(TypeError, cls.generate)
Ejemplo n.º 4
0
 def test_validCreateInvalidClass(self):
     searchpath = os.path.join(self.temp_dir, "*")
     cls = PathMatchInfoGroup(searchpath=searchpath,
                              match=r".*/(\d).*",
                              subclass=unittest.TestCase,
                              subargs={"searchpath": self.temp_dir})
     self.assertEqual(cls._instances, [])
     self.assertEqual(cls.subclass, unittest.TestCase)
Ejemplo n.º 5
0
 def test_empty(self):
     cls = PathMatchInfoGroup()
     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.searchpath, None)
     self.assertEqual(cls.match, None)
     self.assertEqual(cls.subclass, None)
     self.assertEqual(cls.subargs, {})
Ejemplo n.º 6
0
 def test_validGetInvalidClass(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()
     outdict = cls.get()
     self.assertEqual(cls._instances, [])
     self.assertEqual(cls._data, {})
     self.assertEqual(outdict, {})
Ejemplo n.º 7
0
 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])
Ejemplo n.º 8
0
 def test_subclassNone(self):
     cls = PathMatchInfoGroup(subclass=None)
     self.assertEqual(cls.subclass, None)
Ejemplo n.º 9
0
 def test_subclassString(self):
     cls = PathMatchInfoGroup(subclass="abc")
     self.assertEqual(cls.subclass, None)
Ejemplo n.º 10
0
 def test_searchpathInt(self):
     cls = PathMatchInfoGroup(searchpath=True)
     self.assertEqual(cls.searchpath, None)
Ejemplo n.º 11
0
 def test_searchpathExist(self):
     cls = PathMatchInfoGroup(searchpath="/tmp/*")
     self.assertEqual(cls.searchpath, "/tmp/*")
Ejemplo n.º 12
0
 def test_searchpathNotExist(self):
     cls = PathMatchInfoGroup(searchpath="/path/does/not/exist/*")
     self.assertEqual(cls.searchpath, None)
Ejemplo n.º 13
0
 def test_subargsBool(self):
     cls = PathMatchInfoGroup(subargs=True)
     self.assertEqual(cls.subargs, {})
Ejemplo n.º 14
0
 def test_named(self):
     cls = PathMatchInfoGroup(name="Testname")
     self.assertEqual(cls.name, "Testname")
Ejemplo n.º 15
0
 def test_subclassClass(self):
     cls = PathMatchInfoGroup(subclass=TestPathMatchInfoGroup)
     self.assertEqual(cls.subclass, TestPathMatchInfoGroup)
Ejemplo n.º 16
0
 def test_subargsNone(self):
     cls = PathMatchInfoGroup(subargs=None)
     self.assertEqual(cls.subargs, {})
Ejemplo n.º 17
0
 def test_extended(self):
     cls = PathMatchInfoGroup(extended=True)
     self.assertEqual(cls.extended, True)
Ejemplo n.º 18
0
 def test_subargsList(self):
     cls = PathMatchInfoGroup(subargs=[])
     self.assertEqual(cls.subargs, {})
Ejemplo n.º 19
0
 def test_anonymous(self):
     cls = PathMatchInfoGroup(anonymous=True)
     self.assertEqual(cls.anonymous, True)