Beispiel #1
0
    def test_initNotEmpty(self):
        # Setup
        area = getUid()
        path = self.home / area
        S1 = FileCache.StorageArea(str(path))
        ctxt = getUid()
        S1.addContext(ctxt)

        # Test
        S2 = FileCache.StorageArea(str(path))
        k = ctxt in S2.contexts
        self.assertTrue(k)
        shutil.rmtree(str(path))
Beispiel #2
0
 def test_testSimpleCache(self):
     S = FileCache.SimpleCache()
     S.load(
         "http://vospace.esac.esa.int/vospace/sh/4807f490cec42f15d1574442881ccb1f1275bd?dl=1"
     )
     S.get("foo.pdf")
     shutil.rmtree(str(self.home / 'EuclidCache'))
Beispiel #3
0
 def test_test2(self):
     nextContext = getUid()
     S = FileCache.StorageArea(str(self.home / 'EuclidCache'))
     C = S.addContext(nextContext)
     C.load("export.json")
     C.refresh()
     shutil.rmtree(str(self.home / 'EuclidCache'))
Beispiel #4
0
 def test_addContextDup(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     S1.addContext(ctxt)
     S1.addContext(ctxt)
     shutil.rmtree(str(path))
Beispiel #5
0
 def test_delContextNoExist(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     S1.addContext(ctxt)
     S1.deleteContext('foo')
     shutil.rmtree(str(path))
Beispiel #6
0
 def test_getFileNotExists(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     C1 = S1.addContext(ctxt)
     C1.addFile("http://vospace.esac.esa.int/vospace/sh/blah", "foo.pdf")
     C1.getFile("foo.pdf")
     shutil.rmtree(str(path))
Beispiel #7
0
 def test_test3(self):
     next2Context = getUid()
     S = FileCache.StorageArea(str(self.home / 'EuclidCache'))
     C = S.addContext(next2Context)
     C.load(
         "http://vospace.esac.esa.int/vospace/sh/4807f490cec42f15d1574442881ccb1f1275bd?dl=1"
     )
     C.refresh()
     shutil.rmtree(str(self.home / 'EuclidCache'))
Beispiel #8
0
 def test_addContextDirExist(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     dupDir = path / ctxt
     dupDir.mkdir()
     S1.addContext(ctxt, True)
     shutil.rmtree(str(path))
Beispiel #9
0
 def test_addContextNotWritable(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     os.chmod(str(path), 0o0077)
     ctxt = getUid()
     S1.addContext(ctxt)
     os.chmod(str(path), 0o0777)
     shutil.rmtree(str(path))
Beispiel #10
0
 def test_addContext(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     S1.addContext(ctxt)
     cDir = S1.storagePath / ctxt
     self.assertTrue(cDir.exists())
     shutil.rmtree(str(path))
Beispiel #11
0
 def test_delContextNotWritable(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     S1.addContext(ctxt)
     S1.writable = False
     S1.deleteContext(ctxt)
     shutil.rmtree(str(path))
Beispiel #12
0
 def test_addFile(self):
     area = getUid()
     path = self.home / area
     S1 = FileCache.StorageArea(str(path))
     ctxt = getUid()
     C1 = S1.addContext(ctxt)
     C1.addFile(
         "http://vospace.esac.esa.int/vospace/sh/eb9834b594e8da89111147899d15c26dd5ecf9?dl=1",
         "foo.pdf")
     shutil.rmtree(str(path))
Beispiel #13
0
 def test_test1(self):
     S = FileCache.StorageArea(str(self.home / 'EuclidCache'))
     testContext = getUid()
     C = S.addContext(testContext)
     C.addFile(
         "http://vospace.esac.esa.int/vospace/sh/eb9834b594e8da89111147899d15c26dd5ecf9?dl=1",
         "foo.pdf")
     C.getFile("foo.pdf")
     C.export("export.json")
     C.deleteFile("foo.pdf")
     S.deleteContext(testContext)
     shutil.rmtree(str(self.home / 'EuclidCache'))
Beispiel #14
0
 def test_test4(self):
     next3Context = getUid()
     S = FileCache.StorageArea(str(self.home / 'EuclidCache'))
     C = S.addContext(next3Context)  # TODO Should check for existing dirs
     C.addFile(
         "http://vospace.esac.esa.int/vospace/sh/66ee2fc9964193fcc2984e35a25bdee14057f9?dl=1",
         "ick906030_prev.fits")
     C.export("export1.json")
     C.addFile(
         "http://vospace.esac.esa.int/vospace/sp/e09e212133c2c61093431c4eb13ed16e7e31bb36?dl=2",
         "1525190698647O-result.vot")
     C.export("export2.json")
     S.deleteContext(next3Context)  # TODO Check for context
     shutil.rmtree(str(self.home / 'EuclidCache'))
Beispiel #15
0
log("main: start")
signal.signal(signal.SIGINT, sig_int_handler)

# listening socket for incoming client connections
listSock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
listSock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listSock.bind(("",listPort))
log("main: listening on port: "+str(listPort))

# listen for data 100 millisec then time out and do other stuff
listSock.settimeout(0.1)

#clients map
g_clnts = {}

g_fileCache = FileCache.FileCache("server-files.txt")
g_fileCache.load()

g_calCache = CalCache.CalCache("server-calendar.txt")
g_calCache.load()

g_updCache = UpdateCache.UpdateCache("server-updated.txt")
g_updCache.load()

g_episodeCache = EpisodeCache.EpisodeCache("server-episodes.txt")
g_episodeCache.load()

g_grStaCache = GroupStatusCache.GroupStatusCache("server-groupstatus.txt")
g_grStaCache.load()

g_myListCache = MyListCache.MyListCache("server-mylist.txt")
Beispiel #16
0
 def test_test5(self):
     S = FileCache.StorageArea(str(self.home / 'EuclidCache'))
     S.listContexts()
     shutil.rmtree(str(self.home / 'EuclidCache'))
Beispiel #17
0
 def test_initEmpty(self):
     path = self.home / getUid()
     S = FileCache.StorageArea(str(path))
     self.assertTrue(S.storagePath.exists())
     shutil.rmtree(str(path))