# Path: test/framework/api_select.py
# def api(file_name, api_type, login=None, fixed_prefix=None, url_or_dir=None, fake_public_uri=None, invocation_class=None,
#         username=None, password=None):
# 
# Path: test/cfg.py
# class ApiType(Enum):
#     JENKINS = 0
#     SCRIPT = 1
#     MOCK = 2
# 
# Path: test/set_build_description_test.py
# def _clear_description(api, job):
#     if api.api_type == ApiType.SCRIPT:
#         # TODO: There is no build number concept for script api, so we need to ensure a clean start
#         description_file = jp(job.workspace, 'description.txt')
#         if os.path.exists(description_file):
#             os.remove(description_file)


import codecs, os
from os.path import join as jp
from jenkinsflow.flow import serial
from .framework import api_select
from .cfg import ApiType
from .set_build_description_test import _clear_description
        return

    # Read back description and verify
    if api.api_type == ApiType.JENKINS:
        build_url = "/job/" + job.name + '/' + str(build_number)
        dct = api.get_json(build_url, tree="description")
        description = dct['description']

    if api.api_type == ApiType.SCRIPT:
        with codecs.open(jp(job.workspace, 'description.txt'), encoding='utf-8') as ff:
            description = ff.read()

    assert description == expected


def test_set_build_description_unicode_set_build_description_util(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        api.flow_job()
        job_name = 'job-1'
        api.job(job_name, max_fails=0, expect_invocations=1, expect_order=1)

        # Need to read the build number
        if api.api_type == ApiType.SCRIPT:
            # TODO: This can't be called here for Jenkins API. Why?
            job = api.get_job(api.job_name_prefix + job_name)
            _clear_description(api, job)

        with serial(api, timeout=70, job_name_prefix=api.job_name_prefix, report_interval=1, description="«©º") as ctrl1:
            ctrl1.invoke(job_name, password='a', s1='b')


# Path: test/framework/api_select.py
# def api(file_name, api_type, login=None, fixed_prefix=None, url_or_dir=None, fake_public_uri=None, invocation_class=None,
#         username=None, password=None):
# 
# Path: test/cfg.py
# class ApiType(Enum):
#     JENKINS = 0
#     SCRIPT = 1
#     MOCK = 2
# 
# Path: test/set_build_description_test.py
# def _clear_description(api, job):
#     if api.api_type == ApiType.SCRIPT:
#         # TODO: There is no build number concept for script api, so we need to ensure a clean start
#         description_file = jp(job.workspace, 'description.txt')
#         if os.path.exists(description_file):
#             os.remove(description_file)


# Path: test/set_build_description_unicode_test.py
import codecs, os
from os.path import join as jp
from jenkinsflow.flow import serial
from .framework import api_select
from .cfg import ApiType
from .set_build_description_test import _clear_description

        return

    # Read back description and verify
    if api.api_type == ApiType.JENKINS:
        build_url = "/job/" + job.name + '/' + str(build_number)
        dct = api.get_json(build_url, tree="description")
        description = dct['description']

    if api.api_type == ApiType.SCRIPT:
        with codecs.open(jp(job.workspace, 'description.txt'), encoding='utf-8') as ff:
            description = ff.read()

    assert description == expected


def test_set_build_description_unicode_set_build_description_util(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        api.flow_job()
        job_name = 'job-1'
        api.job(job_name, max_fails=0, expect_invocations=1, expect_order=1)

        # Need to read the build number
        if api.api_type == ApiType.SCRIPT:
            # TODO: This can't be called here for Jenkins API. Why?
            job = api.get_job(api.job_name_prefix + job_name)
            _clear_description(api, job)

        with serial(api, timeout=70, job_name_prefix=api.job_name_prefix, report_interval=1, description="«©º") as ctrl1:
            ctrl1.invoke(job_name, password='a', s1='b')


        if api.api_type != ApiType.SCRIPT: