def test_create_and_check_for_transform_collection_content_orm(self):
        """ Transform/Collection/Content (ORM): Test the creation, query, and cancel of a Transform/Collection/Content """

        trans_properties = get_transform_properties()
        coll_properties = get_collection_properties()
        content_properties = get_content_properties()

        trans_id = add_transform(**trans_properties)

        coll_properties['transform_id'] = trans_id
        coll_id = add_collection(**coll_properties)
        coll_id_1 = get_collection_id(
            transform_id=trans_id,
            relation_type=coll_properties['relation_type'])
        assert_equal(coll_id, coll_id_1)

        coll = get_collection(coll_id=coll_id)
        for key in coll_properties:
            assert_equal(coll[key], coll_properties[key])

        update_collection(coll_id, {'status': CollectionStatus.Closed})
        coll = get_collection(coll_id=coll_id)
        assert_equal(coll['status'], CollectionStatus.Closed)

        content_properties['coll_id'] = coll_id
        content_id = add_content(**content_properties)
        content_1 = get_content(coll_id=coll_id,
                                scope=content_properties['scope'],
                                name=content_properties['name'],
                                content_type=ContentType.File)
        content_id_1 = content_1['content_id']
        assert_equal(content_id, content_id_1)

        content = get_content(content_id=content_id)
        update_content(content_id=content_id,
                       parameters={'status': ContentStatus.Lost})
        content = get_content(content_id=content_id)
        assert_equal(content['status'], ContentStatus.Lost)

        delete_content(content_id=content_id)
        c = get_content(content_id=content_id)
        assert_equal(c, None)

        delete_collection(coll_id=coll_id)
        coll = get_collection(coll_id=coll_id)
        assert_equal(coll, None)

        delete_transform(transform_id=trans_id)
        t = get_transform(transform_id=trans_id)
        assert_equal(t, None)
예제 #2
0
def get_collection(coll_id=None, transform_id=None, relation_type=None, to_json=False, session=None):
    """
    Get a collection or raise a NoObject exception.

    :param coll_id: The id of the collection.
    :param transform_id: The transform id related to this collection.
    :param relation_type: The relation between this collection and its transform,
                          such as Input, Output, Log and so on.
    :param to_json: return json format.
    :param session: The database session in use.

    :raises NoObject: If no request is founded.

    :returns: Collection.
    """
    return orm_collections.get_collection(coll_id=coll_id, transform_id=transform_id,
                                          relation_type=relation_type, to_json=to_json,
                                          session=session)