def test_no_cache(): with mock.patch('pomagma.io.s3.BUCKET', new=TEST_BUCKET): for filename in examples('.store_test.test_no_cache'): text = random_uuid() with in_temp_dir(): dump(text, filename) pomagma.io.s3.put(filename) with in_temp_dir(): pomagma.io.s3.get(filename) assert os.path.exists(filename) assert load(filename) == text pomagma.io.s3.remove(filename)
def test_no_cache(): with mock.patch('pomagma.store.BUCKET', new=TEST_BUCKET): for filename in examples('.store_test.test_no_cache'): text = random_uuid() with in_temp_dir(): dump(text, filename) pomagma.store.put(filename) with in_temp_dir(): pomagma.store.get(filename) assert_true(os.path.exists(filename)) assert_equal(load(filename), text) pomagma.store.remove(filename)
def test_write_read(expected): print 'Testing read(write({}))'.format(expected) actual = protobuf_test_pb2.TestMessage() with in_temp_dir(): filename = 'test.pb' with OutFile(filename) as f: f.write(expected) with InFile(filename) as f: f.read(actual) assert actual == expected
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)
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))
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
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)