示例#1
0
def cli(token, url, no_write, workspace):
    """Store your token and API url of NeoLoad Web. The token is read from stdin if none is set.
    The default API url is "https://neoload-api.saas.neotys.com/" """
    if not token:
        if sys.stdin.isatty():
            token = click.prompt("Enter your token", None, True)
        else:
            token = input()
    url = url.strip()
    if url[-1] != '/':
        url += '/'

    __user_data = user_data.do_login(token, url, no_write)

    if workspace is not None:
        if user_data.is_version_lower_than('2.5.0'):
            print(
                "WARNING: The workspace option works only since Neoload Web 2.5.0. The specified workspace is ignored."
            )
        else:
            is_workspace_id = tools.is_mongodb_id(workspace)
            __id = tools.get_id(workspace, workspaces.__resolver,
                                is_workspace_id)
            tools.use(__id, workspaces.meta_key, workspaces.__resolver)

    if sys.stdin.isatty():
        print(__user_data)
示例#2
0
def cli(command, name_or_id):
    """
    ls     # Lists workspaces                                                .
    use    # Remember the workspace you want to work on                      .
    """
    rest_crud.set_current_command()
    if not command:
        print("command is mandatory. Please see neoload workspaces --help")
        return
    if user_data.is_version_lower_than('2.5.0'):
        print("ERROR: This commands works only since Neoload Web 2.5.0")
        return
    rest_crud.set_current_sub_command(command)
    if name_or_id == "cur":
        name_or_id = user_data.get_meta(meta_key)
    is_id = tools.is_mongodb_id(name_or_id)
    # avoid to make two requests if we have not id.
    if command == "ls":
        # The endpoint GET /workspaces/{workspaceId} is not yet implemented
        ws_filter = None
        if name_or_id is not None: ws_filter = "id={}".format(name_or_id)
        tools.ls(None, True, __resolver, ws_filter)
        return

    __id = tools.get_id(name_or_id, __resolver, is_id)

    if command == "use":
        tools.use(__id, meta_key, __resolver)
示例#3
0
def cli(command, name_or_id):
    """
    ls     # Lists workspaces                                                .
    use    # Remember the workspace you want to work on                      .
    """
    if not command:
        print("command is mandatory. Please see neoload workspaces --help")
        return
    if user_data.is_version_lower_than('2.5.0'):
        print("ERROR: This commands works only since Neoload Web 2.5.0")
        return
    rest_crud.set_current_sub_command(command)
    if name_or_id == "cur":
        name_or_id = user_data.get_meta(meta_key)
    is_id = tools.is_mongodb_id(name_or_id)
    # avoid to make two requests if we have not id.
    if command == "ls":
        # The endpoint GET /workspaces/{workspaceId} is not yet implemented
        if name_or_id is not None:
            print(
                "ERROR: Unable to display only one workspace. API endoint not yet implemented. Please use command neoload workspaces ls without name or ID"
            )
        tools.ls(name_or_id, is_id, __resolver)
        return

    __id = tools.get_id(name_or_id, __resolver, is_id)

    if command == "use":
        tools.use(__id, meta_key, __resolver)
示例#4
0
    def test_is_version_lower_than(selfself):
        user_data.set_meta('version', 'SaaS')
        assert user_data.is_version_lower_than('2.5.1') is False
        user_data.set_meta('version', '2.5.1')
        assert user_data.is_version_lower_than('2.5.1') is False
        user_data.set_meta('version', '2.6.1')
        assert user_data.is_version_lower_than('2.5.1') is False
        user_data.set_meta('version', '12.34.56')
        assert user_data.is_version_lower_than('10.0.0') is False
        user_data.set_meta('version', '123.456.789')
        assert user_data.is_version_lower_than('123.0.0') is False

        user_data.set_meta('version', 'legacy')
        assert user_data.is_version_lower_than('2.5.1') is True
        user_data.set_meta('version', '2.5.1')
        assert user_data.is_version_lower_than('2.6.1') is True
        user_data.set_meta('version', '123.456.789')
        assert user_data.is_version_lower_than('124.1.1') is True

        user_data.set_meta('version', '2.0.0')
        assert user_data.is_version_lower_than('legacy') is False
        user_data.set_meta('version', '2.0.0')
        assert user_data.is_version_lower_than('SaaS') is True
示例#5
0
def can_raw_transactions_data():
    return False if user_data.is_version_lower_than('2.6.0') else True
示例#6
0
def base_endpoint():
    return "v2" if user_data.is_version_lower_than('2.5.0') else "v3"