コード例 #1
0
 def test_size_aggregation(self):
     """ test that variable sizes are aggregated properly """
     sdc = cd.simpleCollection()
     makeDummyNC(self.f3)
     n = 30 * 12 * 4 * 12 * 2
     sdc.create_from_disk(self.datadir)
     ss = sdc.contents["subCollections"][0]
     for v in ss.contents["myvariables"]:
         self.assertEqual(n, v.properties["size"])
コード例 #2
0
 def setUp(self):
     self.datadir = tempfile.mkdtemp()
     self.d1 = os.path.join(self.datadir, "subdirectory")
     os.mkdir(self.d1)
     f1 = os.path.join(self.datadir, "file1.nc")
     f2 = os.path.join(self.d1, "file2.nc")
     self.f3 = os.path.join(self.d1, "file3.nc")
     self.files = [f1, f2]
     for f in self.files:
         makeDummyNC(f)
コード例 #3
0
 def setUp(self):
     # create dummy files
     self.datadir = tempfile.mkdtemp()
     self.dummync = os.path.join(self.datadir, "dummy.nc")
     self.dummypy = os.path.join(self.datadir, "dummy.py")
     makeDummyNC(self.dummync)
     self.dummyno = os.path.join(self.datadir, "dummy.notthere")
     self.files = [self.dummync, self.dummypy]
     for f in self.files:
         x = subprocess.check_output(["touch", f])
コード例 #4
0
 def test_update_collection(self):
     sdc = cd.simpleCollection()
     sdc.create_from_disk(self.datadir)
     time.sleep(1)
     os.mkdir(self.d2)
     makeDummyNC(self.f4)
     sdc2 = cd.simpleCollection()
     sdc2.create_from_disk(self.datadir)
     sdc.update()
     # print sdc it's all there
     # print sdc2 all there
     self.assertEqual(sdc, sdc2)
コード例 #5
0
 def setUp(self):
     self.datadir = tempfile.mkdtemp()
     self.d1 = os.path.join(self.datadir, "subdirectory")
     os.mkdir(self.d1)
     self.d2 = os.path.join(self.d1, "deeper")
     self.f1 = os.path.join(self.datadir, "file1.nc")
     self.f2 = os.path.join(self.d1, "file2.nc")
     self.f3 = os.path.join(self.d1, "file3.nc")
     self.f4 = os.path.join(self.d2, "files4.nc")
     self.files = [self.f1, self.f2, self.f3]
     for f in self.files:
         makeDummyNC(f)
コード例 #6
0
 def test_update_file(self):
     sdc = cd.simpleCollection()
     sdc.create_from_disk(self.datadir)
     makeDummyNC(self.f3)
     sdc.update()
     # if the update hasn't picked up the modification date then
     # we'll fail here:
     subdircon = sdc.contents["subCollections"][0]
     self.assertEqual(len(subdircon.contents["dataFiles"]), 2, "possible issue with timing in tests")
     sdc_copy = cd.simpleCollection()
     sdc_copy.create_from_disk(self.datadir)
     self.assertEqual(sdc_copy, sdc)
コード例 #7
0
 def test_checkondisk2(self):
     """ Test that we can see extra files in a directory"""
     # note that we don't have guaranteed resolution in time of <1s
     # so this currently fails.
     # need a c extension to get to st_mtim not st_mtime.
     # base around http://goo.gl/W2Twb ?
     sdc = cd.simpleCollection()
     sdc.create_from_disk(self.datadir)
     time.sleep(0.1)
     x = os.listdir(self.d1)  # wait,flush
     makeDummyNC(self.f3)
     time.sleep(0.1)
     x = os.listdir(self.d1)  # wait,flush
     self.assertRaises(cd.ValidationError, sdc.check_ondisk)
コード例 #8
0
    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)
コード例 #9
0
 def test_create_and_readdummyfile(self):
     
     r=ch.makeDummyNC(self.dummy_file)
     self.assertEqual(r,(30,12,4,12))
     
     r=ch.cdmsHandler(self.dummy_file)