Esempio n. 1
0
def test_stale_cache():
    with mock.patch('pomagma.store.BUCKET', new=TEST_BUCKET):
        for filename in examples('.store_test.test_stale_cache'):
            text = random_uuid()
            stale_text = random_uuid()
            with in_temp_dir():
                dump(text, filename)
                pomagma.store.put(filename)
                dump(stale_text, filename)
                pomagma.store.bzip2(filename)
                pomagma.store.get(filename)
                assert_true(os.path.exists(filename))
                assert_equal(load(filename), text)
                pomagma.store.remove(filename)
Esempio n. 2
0
def test_stale_cache():
    with mock.patch('pomagma.io.s3.BUCKET', new=TEST_BUCKET):
        for filename in examples('.store_test.test_stale_cache'):
            text = random_uuid()
            stale_text = random_uuid()
            with in_temp_dir():
                dump(text, filename)
                pomagma.io.s3.put(filename)
                dump(stale_text, filename)
                pomagma.io.s3.bzip2(filename)
                pomagma.io.s3.get(filename)
                assert os.path.exists(filename)
                assert load(filename) == text
                pomagma.io.s3.remove(filename)
Esempio n. 3
0
def test_7z():
    for filename in examples('.store_test.test_7z'):
        text = random_uuid()
        with in_temp_dir():
            dump(text, filename)
            filename_ext = pomagma.store.archive_7z(filename)
            assert_true(os.path.exists(filename_ext))
            os.remove(filename)
            pomagma.store.extract_7z(filename_ext)
            assert_true(os.path.exists(filename))
            assert_equal(load(filename), text)
Esempio n. 4
0
def test_7z():
    for filename in examples('.store_test.test_7z'):
        text = random_uuid()
        with in_temp_dir():
            dump(text, filename)
            filename_ext = pomagma.io.s3.archive_7z(filename)
            assert os.path.exists(filename_ext)
            os.remove(filename)
            pomagma.io.s3.extract_7z(filename_ext)
            assert os.path.exists(filename)
            assert load(filename) == text
Esempio n. 5
0
def test_s3():
    with mock.patch('pomagma.store.BUCKET', new=TEST_BUCKET):
        for filename in examples('.store_test.test_s3'):
            text = random_uuid()
            with in_temp_dir():
                dump(text, filename)
                print 'putting to s3...',
                pomagma.store.s3_lazy_put(filename)
                print 'done'
            assert_true(pomagma.store.s3_exists(filename))
            with in_temp_dir():
                print 'getting from s3...',
                pomagma.store.s3_lazy_get(filename)
                print 'done'
                assert_true(os.path.exists(filename))
                assert_equal(load(filename), text)
            print 'removing from s3...',
            pomagma.store.s3_remove(filename)
            print 'done'
            assert_false(pomagma.store.s3_exists(filename))
Esempio n. 6
0
def test_s3():
    with mock.patch('pomagma.io.s3.BUCKET', new=TEST_BUCKET):
        for filename in examples('.store_test.test_s3'):
            text = random_uuid()
            with in_temp_dir():
                dump(text, filename)
                print 'putting to s3...',
                pomagma.io.s3.s3_lazy_put(filename)
                print 'done'
            assert pomagma.io.s3.s3_exists(filename)
            with in_temp_dir():
                print 'getting from s3...',
                pomagma.io.s3.s3_lazy_get(filename)
                print 'done'
                assert os.path.exists(filename)
                assert load(filename) == text
            print 'removing from s3...',
            pomagma.io.s3.s3_remove(filename)
            print 'done'
            assert not pomagma.io.s3.s3_exists(filename)
Esempio n. 7
0
def examples(suffix):
    for depth in range(3):
        dirs = [random_uuid() for _ in range(depth)]
        filename = random_uuid() + suffix
        path = apply(os.path.join, dirs + [filename])
        yield path