예제 #1
0
 def test_copy_a_file_child_file_exists(self):
     allowed = dict()
     allowed['name'] = (str, "", "Directory name")
     shutil.copy('files/another_alphatest', 'childdir/alphatest')
     mybc = BaseChecker(allowed, name='files')
     mybc.copy_a_file('childdir', 'third_alphatest', 'alphatest')
     compare = MASTFile("files/another_alphatest")
     myfile = MASTFile("childdir/alphatest")
     self.assertEqual(compare.data, myfile.data)
예제 #2
0
 def test_copy_a_file_child_file_exists(self):
     allowed=dict()
     allowed['name']=(str,"","Directory name")
     shutil.copy('files/another_alphatest','childdir/alphatest')
     mybc=BaseChecker(allowed,name='files')
     mybc.copy_a_file('childdir','third_alphatest','alphatest')
     compare=MASTFile("files/another_alphatest")
     myfile=MASTFile("childdir/alphatest")
     self.assertEqual(compare.data, myfile.data)
예제 #3
0
 def test_softlink_a_file_emptyparentfile(self):
     allowed=dict()
     allowed['name']=(str,"","Directory name")
     mybc=BaseChecker(allowed,name='files')
     mybc.softlink_a_file('childdir','emptyfile')
     myfiles=dirutil.walkfiles("childdir")
     print myfiles
     #self.assertTrue("childdir/CHGCAR" in myfiles)
     listme=subprocess.Popen("ls -l childdir",stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     listres=listme.communicate()[0]
     listme.wait()
     print listres
     self.assertTrue("files/emptyfile" in listres)
예제 #4
0
 def test_softlink_a_file_child_file_exists(self):
     allowed=dict()
     allowed['name']=(str,"","Directory name")
     shutil.copy('files/another_alphatest','childdir/alphatest')
     mybc=BaseChecker(allowed,name='files')
     mybc.softlink_a_file('childdir','alphatest')
     myfiles=dirutil.walkfiles("childdir")
     print myfiles
     #self.assertTrue("childdir/CHGCAR" in myfiles)
     listme=subprocess.Popen("ls -l childdir",stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     listres=listme.communicate()[0]
     listme.wait()
     print listres
     self.assertFalse("files/alphatest" in listres)
     self.assertTrue("childdir/alphatest" in myfiles)
예제 #5
0
 def test_softlink_a_file_emptyparentfile(self):
     allowed = dict()
     allowed['name'] = (str, "", "Directory name")
     mybc = BaseChecker(allowed, name='files')
     mybc.softlink_a_file('childdir', 'emptyfile')
     myfiles = dirutil.walkfiles("childdir")
     print myfiles
     #self.assertTrue("childdir/CHGCAR" in myfiles)
     listme = subprocess.Popen("ls -l childdir",
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               shell=True)
     listres = listme.communicate()[0]
     listme.wait()
     print listres
     self.assertTrue("files/emptyfile" in listres)
예제 #6
0
 def test_softlink_a_file_child_file_exists(self):
     allowed = dict()
     allowed['name'] = (str, "", "Directory name")
     shutil.copy('files/another_alphatest', 'childdir/alphatest')
     mybc = BaseChecker(allowed, name='files')
     mybc.softlink_a_file('childdir', 'alphatest')
     myfiles = dirutil.walkfiles("childdir")
     print myfiles
     #self.assertTrue("childdir/CHGCAR" in myfiles)
     listme = subprocess.Popen("ls -l childdir",
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               shell=True)
     listres = listme.communicate()[0]
     listme.wait()
     print listres
     self.assertFalse("files/alphatest" in listres)
     self.assertTrue("childdir/alphatest" in myfiles)
예제 #7
0
 def test_softlink_a_file_child_softlink_exists(self):
     print "CURDIR: ", os.getcwd()
     allowed=dict()
     allowed['name']=(str,"","Directory name")
     os.chdir("childdir")
     linkme=subprocess.Popen("ln -s ../files/another_alphatest alphatest",shell=True)
     linkme.wait()
     os.chdir(testdir)
     mybc=BaseChecker(allowed,name='files')
     mybc.softlink_a_file('childdir','alphatest')
     myfiles=dirutil.walkfiles("childdir")
     print myfiles
     #self.assertTrue("childdir/CHGCAR" in myfiles)
     listme=subprocess.Popen("ls -l childdir",stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
     listres=listme.communicate()[0]
     listme.wait()
     print listres
     self.assertTrue("files/another_alphatest" in listres)
     self.assertTrue("childdir/alphatest" in myfiles)
예제 #8
0
 def test_softlink_a_file_child_softlink_exists(self):
     print "CURDIR: ", os.getcwd()
     allowed = dict()
     allowed['name'] = (str, "", "Directory name")
     os.chdir("childdir")
     linkme = subprocess.Popen("ln -s ../files/another_alphatest alphatest",
                               shell=True)
     linkme.wait()
     os.chdir(testdir)
     mybc = BaseChecker(allowed, name='files')
     mybc.softlink_a_file('childdir', 'alphatest')
     myfiles = dirutil.walkfiles("childdir")
     print myfiles
     #self.assertTrue("childdir/CHGCAR" in myfiles)
     listme = subprocess.Popen("ls -l childdir",
                               stdout=subprocess.PIPE,
                               stderr=subprocess.PIPE,
                               shell=True)
     listres = listme.communicate()[0]
     listme.wait()
     print listres
     self.assertTrue("files/another_alphatest" in listres)
     self.assertTrue("childdir/alphatest" in myfiles)
예제 #9
0
 def test_softlink_a_file_no_parent_file(self):
     allowed = dict()
     allowed['name'] = (str, "", "Directory name")
     mybc = BaseChecker(allowed, name='files')
     self.assertRaises(MASTError, mybc.softlink_a_file, 'childdir',
                       'nofile')
예제 #10
0
 def test_copy_a_file_emptyparentfile(self):
     allowed = dict()
     allowed['name'] = (str, "", "Directory name")
     mybc = BaseChecker(allowed, name='files')
     mybc.copy_a_file('childdir', 'emptyfile', 'childalpha')
     self.assertTrue(os.path.isfile('childdir/childalpha'))
예제 #11
0
 def test_copy_a_file_emptyparentfile(self):
     allowed=dict()
     allowed['name']=(str,"","Directory name")
     mybc=BaseChecker(allowed,name='files')
     mybc.copy_a_file('childdir','emptyfile','childalpha')
     self.assertTrue(os.path.isfile('childdir/childalpha'))