Ejemplo n.º 1
0
    def test_storage_path_context_lock(self):
        app = Swarm(__name__, instance_path='temp')
        storage = app.storage('state', 'subprocess')

        pth = os.path.abspath(storage)
        with storage.locked():
            self.assertTrue(os.path.exists('../subprocess.lock'))
        shutil.rmtree('temp')
Ejemplo n.º 2
0
 def test_storage_path_context(self):
     app = Swarm(__name__, instance_path='temp')
     storage = app.storage('state', 'subprocess')
     initial = os.path.abspath(os.curdir)
     pth = os.path.abspath(storage)
     with storage:
         self.assertTrue(os.path.exists(pth))
         self.assertTrue(os.path.abspath(os.curdir) == pth)
     self.assertTrue(os.path.abspath(os.curdir) == initial)
     shutil.rmtree('temp')
Ejemplo n.º 3
0
    def test_open(self):
        app = Swarm(__name__, instance_path='temp')
        storage = app.storage('state', 'subprocess')
        with storage.open('test.txt', 'w') as test:
            test.write('asd')

        with open('temp/state/subprocess/test.txt', 'r') as test:
            self.assertTrue(test.read() == 'asd')

        shutil.rmtree('temp')
Ejemplo n.º 4
0
    def test_locked_open(self):
        app = Swarm(__name__, instance_path='temp')
        storage = app.storage('state', 'subprocess')
        with storage.open('test.txt', 'w', locked=True) as test:
            test.write('asd')
            self.assertTrue(os.path.exists(os.path.join(storage, 'test.txt.lock')))

        with open('temp/state/subprocess/test.txt', 'r') as test:
            self.assertTrue(test.read() == 'asd')

        shutil.rmtree('temp')
Ejemplo n.º 5
0
 def test_storage_path(self):
     app = Swarm(__name__, instance_path='temp')
     storage = app.storage('state', 'subprocess')
     self.assertFalse(os.path.exists('temp'))
Ejemplo n.º 6
0
 def test_folder_with_default_instance_path(self):
     app = Swarm(__name__)
     self.assertTrue(app.storage('state', 'subprocess')     \
         == os.path.abspath('var/test_fs_vault-instance/state/subprocess'))