Example #1
0
    def test_download_object_by_name(self, cloud):
        container = ContainerFactory()

        obj = ObjectFactory(container=container.name)
        data = cloud.object_store.download_object(obj.name, container.name)

        assert data == obj.data
Example #2
0
    def test_delete_object_by_name(self, cloud):
        container = ContainerFactory()
        obj = ObjectFactory(container=container.name)

        cloud.object_store.delete_object(obj.name, container=container.name)
        actual_objects = list(cloud.object_store.objects(container))

        assert len(actual_objects) == 0
Example #3
0
    def test_upload_object_with_container_name(self, cloud):
        container = ContainerFactory(name='upload_with_name')

        obj = cloud.object_store.upload_object(container.name,
                                               'uploaded',
                                               data=b'Uploaded object')

        assert obj.container == container.name
        assert obj.name == 'uploaded'
        assert obj.data == b'Uploaded object'
Example #4
0
    def test_retrieve_all_containers(self, cloud):
        expected_containers = ContainerFactory.create_batch(2)
        actual_containers = [
            c for c in cloud.object_store.containers()
            if c.name.startswith(TEST_CONTAINERS_PREFIX)
        ]
        assert len(actual_containers) == len(expected_containers)

        for actual, expected in zip(actual_containers, expected_containers):
            assert actual.name == expected.name
Example #5
0
    def test_get_object_by_name(self, cloud):
        container = ContainerFactory()

        expected = ObjectFactory(container=container.name)
        actual = cloud.object_store.get_object(expected.name, container.name)

        assert actual.id == expected.id
        assert actual.container == expected.container
        assert actual.name is None
        assert actual.data is None
Example #6
0
    def test_retrieve_all_objects_with_container_name(self, cloud):
        container = ContainerFactory()

        actual_objects = sorted(
            ObjectFactory.create_batch(2, container=container.name),
            key=lambda o: o.name,
        )
        expected_objects = sorted(
            cloud.object_store.objects(container.name),
            key=lambda o: o.name,
        )
        assert len(actual_objects) == len(expected_objects)

        for actual, expected in zip(actual_objects, expected_objects):
            assert actual.name == expected.name
Example #7
0
    def test_delete_container_by_name(self, cloud):
        container = ContainerFactory()
        cloud.object_store.delete_container(container.name)

        with pytest.raises(exceptions.NotFoundException):
            cloud.object_store.get_container_metadata(container)
Example #8
0
 def test_get_container_by_name(self, cloud):
     expected = ContainerFactory()
     actual = cloud.object_store.get_container_metadata(expected.name)
     assert actual.name == expected.name
Example #9
0
 def test_get_container(self, cloud):
     expected = ContainerFactory()
     actual = cloud.object_store.get_container_metadata(expected)
     assert actual is expected
Example #10
0
    def test_download_not_existing_object(self, cloud):
        container = ContainerFactory()

        with pytest.raises(exceptions.ResourceNotFound):
            cloud.object_store.download_object('missing', container.name)