def test_datafile_check(self): """ Test the validation of modification times on disk """ sdf = cd.simpleDataFile() sdf.create_from_disk(self.dummync) self.assertTrue(sdf.check_ondisk) ig = subprocess.check_output(["touch", self.dummync]) self.assertRaises(cd.ValidationError, sdf.check_ondisk)
def test_datafile(self): """ test instantiating and using with dummy data """ sdf = cd.simpleDataFile() sdf.create_from_disk(self.dummync) # just check one property: path = sdf.properties["path"] self.assertEqual(path, self.dummync) # check there is a checksum csum = sdf.properties["checksum"] self.assertEqual(len(csum), 40)
def setUp(self): # first don't go near disk self.dummysf = cd.simpleDataFile() self.now = datetime.datetime.now().isoformat() self.dummyproperties = { "modificationDate": self.now, "checksum": "dummychecksum", "path": "dummypath", "name": "dummyname", } for k in self.dummyproperties: self.dummysf.modify(k, self.dummyproperties[k]) self.dummysc = cd.simpleCollection(cd.simpleSerialiser) for k in ["modificationDate"]: self.dummysc.modify(k, self.dummyproperties[k]) self.dummysc.add("dataFiles", self.dummysf) # now what we need for physical CF metadata serialisation self.datadir = tempfile.mkdtemp() self.f1 = os.path.join(self.datadir, "file1.nc") makeDummyNC(self.f1)
def test_datafile_doesntExist(self): """ Test no file """ sdf = cd.simpleDataFile() self.assertRaises(ValueError, sdf.create_from_disk, self.dummyno)
def test_datafile_wrongsort(self): """ Test ignoring unrecognisable data """ sdf = cd.simpleDataFile() self.assertRaises(ValueError, sdf.create_from_disk, self.dummypy)