예제 #1
0
def includeme(config):  # pragma: no cover
    beeldbank = Collection(name='cheeses',
                           object_store=PairTreeFileSystemStore(
                               os.path.expanduser('~/data/cheeses/data')))
    config.registry.collections[beeldbank.name] = beeldbank

    besluiten = Collection(name='trees',
                           object_store=PairTreeFileSystemStore(
                               os.path.expanduser('~/data/trees/data')))
    config.registry.collections[besluiten.name] = besluiten
예제 #2
0
def collections_include(config, store_dir):
    test_collection = Collection(
        name='TEST_COLLECTION',
        object_store=PairTreeFileSystemStore(store_dir))
    config.registry.collections[test_collection.name] = test_collection
예제 #3
0
class TestPairTreeStore(unittest.TestCase):
    '''series of tests to check the implementation of the PairTreeFileSystemStore.
        Not really unittests, more integration tests'''
    def setUp(self):
        self.temp = tempdir.TempDir()
        store_dir = os.path.join(os.path.abspath(self.temp.name), 'test_data')
        self.store = PairTreeFileSystemStore(store_dir)

    def tearDown(self):
        self.temp.dissolve()

    def test_usage_scenario(self):
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, 'some test data')
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(1, len(object_list))
        self.assertEqual(object_key, object_list[0])
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual('some test data', object_value)
        self.store.delete_object(container_key, object_key)
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(0, len(object_list))

    def test_usage_real_file(self):
        here = os.path.dirname(__file__)
        testdata = os.path.join(here, '../', 'fixtures/kasteel.jpg')
        with open(testdata, 'rb') as f:
            bdata = f.read()
        filesize = len(bdata)
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, bdata)
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(1, len(object_list))
        self.assertEqual(object_key, object_list[0])
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual(filesize, len(object_value))
        self.assertEqual(bdata, object_value)
        self.store.delete_object(container_key, object_key)
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(0, len(object_list))

    def test_update_scenario(self):
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, 'some test data')
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual('some test data', object_value)
        self.store.update_object(container_key, object_key, 'updated data')
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual('updated data', object_value)

    def test_delete_nonexisting(self):
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, 'some test data')
        self.assertRaises(NotFoundException, self.store.delete_object,
                          container_key, 'nogo')

    def test_add_object_to_nonexisting_container(self):
        error_raised = False
        self.store.create_container('x')
        try:
            self.store.create_object('xx', '253', 'some test data')
        except NotFoundException:
            error_raised = True
        self.assertTrue(error_raised)

    def test_delete_container(self):
        self.store.create_container('x')
        self.store.delete_container('x')

    def test_delete_nonexisting_container(self):
        error_raised = False
        try:
            self.store.delete_container('x')
        except NotFoundException:
            error_raised = True
        self.assertTrue(error_raised)
예제 #4
0
 def setUp(self):
     self.temp = tempdir.TempDir()
     store_dir = os.path.join(os.path.abspath(self.temp.name), 'test_data')
     self.store = PairTreeFileSystemStore(store_dir)
예제 #5
0
def includeme(config):  # pragma: no cover
    default = Collection(
        name='default',
        object_store=PairTreeFileSystemStore(
            config.registry.settings['default.store.data_dir']))
    config.registry.collections[default.name] = default
예제 #6
0
class TestPairTreeStore(unittest.TestCase):
    '''series of tests to check the implementation of the PairTreeFileSystemStore.
        Not really unittests, more integration tests'''

    def setUp(self):
        self.temp = tempdir.TempDir()
        store_dir = os.path.join(os.path.abspath(self.temp.name), 'test_data')
        self.store = PairTreeFileSystemStore(store_dir)

    def tearDown(self):
        self.temp.dissolve()

    def test_usage_scenario(self):
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, 'some test data')
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(1, len(object_list))
        self.assertEqual(object_key, object_list[0])
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual('some test data', object_value)
        self.store.delete_object(container_key, object_key)
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(0, len(object_list))

    def test_usage_real_file(self):
        here = os.path.dirname(__file__)
        testdata = os.path.join(here, '../', 'fixtures/kasteel.jpg')
        with open(testdata, 'rb') as f:
            bdata = f.read()
        filesize = len(bdata)
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, bdata)
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(1, len(object_list))
        self.assertEqual(object_key, object_list[0])
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual(filesize, len(object_value))
        self.assertEqual(bdata, object_value)
        self.store.delete_object(container_key, object_key)
        object_list = self.store.list_object_keys_for_container(container_key)
        self.assertEqual(0, len(object_list))

    def test_update_scenario(self):
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, 'some test data')
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual('some test data', object_value)
        self.store.update_object(container_key, object_key, 'updated data')
        object_value = self.store.get_object(container_key, object_key)
        self.assertEqual('updated data', object_value)

    def test_delete_nonexisting(self):
        container_key = 'testing'
        object_key = 'metadata'
        self.store.create_container(container_key)
        self.store.create_object(container_key, object_key, 'some test data')
        self.assertRaises(NotFoundException, self.store.delete_object, container_key, 'nogo')

    def test_add_object_to_nonexisting_container(self):
        error_raised = False
        self.store.create_container('x')
        try:
            self.store.create_object('xx', '253', 'some test data')
        except NotFoundException:
            error_raised = True
        self.assertTrue(error_raised)

    def test_delete_container(self):
        self.store.create_container('x')
        self.store.delete_container('x')

    def test_delete_nonexisting_container(self):
        error_raised = False
        try:
            self.store.delete_container('x')
        except NotFoundException:
            error_raised = True
        self.assertTrue(error_raised)
예제 #7
0
 def setUp(self):
     self.temp = tempdir.TempDir()
     store_dir = os.path.join(os.path.abspath(self.temp.name), 'test_data')
     self.store = PairTreeFileSystemStore(store_dir)