Exemple #1
0
def tk_test_shotgun():
    """
    Getting credentials from TK_TOOLCHAIN
    """
    sg = get_toolkit_user().create_sg_connection()

    return sg
Exemple #2
0
def shotgun():
    """
    Provides a connection to Shotgun.
    """
    sg = get_toolkit_user().create_sg_connection()

    return sg
def context():
    # Get credentials from TK_TOOLCHAIN
    sg = get_toolkit_user().create_sg_connection()

    # Get the Demo Animation project id
    filters = [["name", "is", "Demo: Animation"]]
    project = sg.find_one("Project", filters)

    return project
Exemple #4
0
def tk_test_current_user(tk_test_shotgun):
    """
    Get current user

    :returns: The current user id and name
    """
    user = get_toolkit_user()
    username = tk_test_shotgun.find_one(
        "HumanUser", [["login", "is", str(user)]], ["name"])

    return username
Exemple #5
0
def test_context_tab(about_box):
    """
    Ensure the content of the context browser is complete.
    """
    about_box.select_context_tab()
    user = authentication.get_toolkit_user()
    server = urllib.parse.urlparse(user.host).netloc
    # The first line contains the server name, which we do not want to display during
    # automation on the cloud.
    assert about_box.context_browser.items[1:] == [
        "Asset Acorn\nAs to size, Alice hastily but Im not looking for eggs, as it spoke. As wet as ever, said Alice to herself, and fanned herself one",
        "Pipeline Step Art\nNo Description",
        "Task Art\nStatus: fin\nAssigned to: Artist 3",
    ]
Exemple #6
0
def test_current_user(tk_test_shotgun, tk_test_current_user):
    """
    Ensure getting current_user
    """
    # Getting current user
    user = get_toolkit_user()
    username = tk_test_shotgun.find_one(
        "HumanUser", [["login", "is", str(user)]], ["name"])

    # Getting current user with tk_test_current_user fixture
    current_user = tk_test_current_user

    # Make sure both user are identical.
    assert username == current_user
Exemple #7
0
def test_credentials(tk_test_shotgun):
    """
    Ensure getting credentials
    """
    # Get credentials from the fixture and fin local storage with it
    fixture_credentials = tk_test_shotgun

    # Use credentials from fixture to get storage info
    storage_name = create_unique_name("Toolkit UI Automation")
    local_storage1 = fixture_credentials.find_one(
        "LocalStorage", [["code", "is", storage_name]], ["code"])

    # Getting credentials from TK_TOOLCHAIN
    tk_toolchain_crendentials = get_toolkit_user().create_sg_connection()

    # Use credentials from TK_TOOLCHAIN to get storage info
    local_storage2 = tk_toolchain_crendentials.find_one(
        "LocalStorage", [["code", "is", storage_name]], ["code"])

    # Make sure both storage info are identical.
    assert local_storage1 == local_storage2
def _start_engine(repo, entity_type, entity_id, config):
    """
    Bootstraps Toolkit and uses the app in the current repo.

    :param tk_toolchain.repo.Repository: Repository for the current folder.

    :returns: An engine instance.
    """
    import sgtk

    # Initialize logging to disk and on screen.
    sgtk.LogManager().initialize_base_file_handler("tk-run-app-{0}".format(
        repo.name))
    sgtk.LogManager().initialize_custom_handler()

    util.merge_into_environment_variables(
        repo.get_roots_environment_variables())
    util.merge_into_environment_variables(get_test_engine_environment())
    os.environ["SHOTGUN_TK_APP_LOCATION"] = repo.root

    # Standard Toolkit bootstrap code.
    user = authentication.get_toolkit_user()
    mgr = sgtk.bootstrap.ToolkitManager(user)
    mgr.progress_callback = _progress_callback
    # Do not look in Shotgun for a config to load, we absolutely want to
    # use the config referenced by the base_configuration.
    mgr.do_shotgun_config_lookup = False
    mgr.base_configuration = "sgtk:descriptor:path?path={0}".format(
        config if config else get_config_location())

    if entity_type == "Project" and entity_id is None:
        context = user.create_sg_connection().find_one(
            "Project",
            [["is_template", "is", False]],
            order=[{
                "direction": "asc",
                "field_name": "id"
            }],
        )
    elif entity_id is None:
        context = user.create_sg_connection().find_one(entity_type, [],
                                                       order=[{
                                                           "direction":
                                                           "asc",
                                                           "field_name":
                                                           "id"
                                                       }])
    elif entity_type and entity_id:
        context = user.create_sg_connection().find_one(
            entity_type, [["id", "is", entity_id]])
    else:
        raise RuntimeError("Bad context argument for {0}@{1}".format(
            entity_type, entity_id))

    if context is None:
        raise RuntimeError(
            "Context enity {0} with id {1} could not be found.".format(
                entity_type, entity_id))

    print("Python Version: {0}".format(sys.version))

    print("Launching test engine in context {0}".format(context))

    # Find the first non-template project and use it.
    # In the future we could have command-line arguments that allow to specify that.
    engine = mgr.bootstrap_engine("tk-testengine", context)
    return engine
Exemple #9
0
def context():
    # Tasks in Toolkit Loader2 UI Automation project which we're going to use
    # in different test cases.
    # Get credentials from TK_TOOLCHAIN
    sg = get_toolkit_user().create_sg_connection()

    # Create or update the integration_tests local storage with the current test run
    storage_name = "Loader UI Tests"
    local_storage = sg.find_one("LocalStorage", [["code", "is", storage_name]],
                                ["code"])
    if local_storage is None:
        local_storage = sg.create("LocalStorage", {"code": storage_name})
    # Always update local storage path
    local_storage["path"] = os.path.expandvars("${SHOTGUN_CURRENT_REPO_ROOT}")
    sg.update("LocalStorage", local_storage["id"],
              {"windows_path": local_storage["path"]})

    # Make sure there is not already an automation project created
    filters = [["name", "is", "Toolkit Loader2 UI Automation"]]
    existed_project = sg.find_one("Project", filters)
    if existed_project is not None:
        sg.delete(existed_project["type"], existed_project["id"])

    # Create a new project with the Film VFX Template
    project_data = {
        "sg_description": "Project Created by Automation",
        "name": "Toolkit Loader2 UI Automation",
    }
    new_project = sg.create("Project", project_data)

    # Create a Sequence to be used by the Shot creation
    sequence_data = {
        "project": {
            "type": new_project["type"],
            "id": new_project["id"]
        },
        "code": "seq_001",
        "sg_status_list": "ip",
    }
    new_sequence = sg.create("Sequence", sequence_data)

    # Create a new shot
    shot_data = {
        "project": {
            "type": new_project["type"],
            "id": new_project["id"]
        },
        "sg_sequence": {
            "type": new_sequence["type"],
            "id": new_sequence["id"]
        },
        "code": "shot_001",
        "sg_status_list": "ip",
    }
    sg.create("Shot", shot_data)

    # Create a new asset
    asset_data = {
        "project": {
            "type": new_project["type"],
            "id": new_project["id"]
        },
        "code": "AssetAutomation",
        "description": "This asset was created by the Loader2 UI automation",
        "sg_status_list": "ip",
    }
    asset = sg.create("Asset", asset_data)

    # File to publish
    file_to_publish = os.path.normpath(
        os.path.expandvars("${TK_TEST_FIXTURES}/files/images/achmed.JPG"))

    # Create a published file
    publish_data = {
        "project": {
            "type": new_project["type"],
            "id": new_project["id"]
        },
        "code": "achmed.JPG",
        "name": "achmed.JPG",
        "description": "This file was published by the Loader2 UI automation",
        "path": {
            "local_path": file_to_publish
        },
        "entity": asset,
        "version_number": 1,
    }
    sg.create("PublishedFile", publish_data)

    return new_project