def testBasic(self):
        key = "test_FileCache"
        obj = {"foo": "bar"}

        FileCache.clearAll(key)
        fc = FileCache(key, "/no_exist", 1)
        self.checkFileCache(fc)
        self.assertEqual(fc.no_exist, True)

        ret = fc.add(obj)
        self.assertEqual(ret, False)
        self.assertEqual(fc.dirty, True)

        exe_path = Testing.find_moose_test_exe()
        fc = FileCache(key, exe_path, 1)
        self.checkFileCache(fc)
        val = fc.read()
        self.assertEqual(val, None)

        ret = fc.add(obj)
        self.assertEqual(ret, True)
        self.assertEqual(fc.dirty, False)
        ret = fc.add(obj)
        self.assertEqual(ret, False)
        self.assertEqual(fc.dirty, False)
        val = fc.read()
        self.assertEqual(val, obj)
        self.assertEqual(fc.dirty, False)

        fc = FileCache(key, exe_path, 1)
        self.assertEqual(fc.dirty, False)
        # different data version
        fc = FileCache(key, exe_path, 2)
        self.assertEqual(fc.dirty, True)


        FileCache.clearAll(key)
Beispiel #2
0
    def testBasic(self):
        key = "test_FileCache"
        obj = {"foo": "bar"}

        FileCache.clearAll(key)
        fc = FileCache(key, "/no_exist", 1)
        self.checkFileCache(fc)
        self.assertEqual(fc.no_exist, True)

        ret = fc.add(obj)
        self.assertEqual(ret, False)
        self.assertEqual(fc.dirty, True)

        exe_path = Testing.find_moose_test_exe()
        fc = FileCache(key, exe_path, 1)
        self.checkFileCache(fc)
        val = fc.read()
        self.assertEqual(val, None)

        ret = fc.add(obj)
        self.assertEqual(ret, True)
        self.assertEqual(fc.dirty, False)
        ret = fc.add(obj)
        self.assertEqual(ret, False)
        self.assertEqual(fc.dirty, False)
        val = fc.read()
        self.assertEqual(val, obj)
        self.assertEqual(fc.dirty, False)

        fc = FileCache(key, exe_path, 1)
        self.assertEqual(fc.dirty, False)
        # different data version
        fc = FileCache(key, exe_path, 2)
        self.assertEqual(fc.dirty, True)


        FileCache.clearAll(key)
Beispiel #3
0
 def clearCache():
     FileCache.clearAll(ExecutableInfo.SETTINGS_KEY)
     FileCache.clearAll(ExecutableInfo.SETTINGS_KEY_TEST_OBJS)
Beispiel #4
0
 def clearCache():
     FileCache.clearAll(ExecutableInfo.SETTINGS_KEY)
     FileCache.clearAll(ExecutableInfo.SETTINGS_KEY_TEST_OBJS)