# 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


import pytest
from jenkinsflow.flow import serial
from .framework import api_select
from .cfg import ApiType
# Copyright (c) 2017 Lars Hupfeldt Nielsen, Hupfeldt IT
# All rights reserved. This work is under a BSD license, see LICENSE.TXT.





def _job_name(api, short_name):
    return api.job_name_prefix + short_name, short_name


@pytest.mark.not_apis(ApiType.MOCK, ApiType.SCRIPT)
def test_enable_disable_disable_enable(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        full_name, short_name = _job_name(api, 'j1')
        api.job(short_name, max_fails=0, expect_invocations=0, expect_order=None)

        api.poll()
        job = api.get_job(full_name)
        job.disable()
        job.enable()



# 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/enable_disable_test.py
import pytest
from jenkinsflow.flow import serial
from .framework import api_select
from .cfg import ApiType

# Copyright (c) 2017 Lars Hupfeldt Nielsen, Hupfeldt IT
# All rights reserved. This work is under a BSD license, see LICENSE.TXT.





def _job_name(api, short_name):
    return api.job_name_prefix + short_name, short_name


@pytest.mark.not_apis(ApiType.MOCK, ApiType.SCRIPT)
def test_enable_disable_disable_enable(api_type):
    with api_select.api(__file__, api_type, login=True) as api:
        full_name, short_name = _job_name(api, 'j1')
        api.job(short_name, max_fails=0, expect_invocations=0, expect_order=None)

        api.poll()
        job = api.get_job(full_name)
        job.disable()
        job.enable()



@pytest.mark.not_apis(ApiType.MOCK, ApiType.SCRIPT)