# Path: yagocd/resources/job.py
# class JobManager(BaseManager, RequireParamMixin):
# class JobInstance(Base):
#     RESOURCE_PATH = '{base_api}/jobs'
#     def __init__(
#         self,
#         session,
#         pipeline_name=None,
#         stage_name=None,
#         job_name=None,
#     ):
#     def scheduled(self):
#     def history(self, pipeline_name=None, stage_name=None, job_name=None, offset=0):
#     def __init__(self, session, data, stage):
#     def pipeline_name(self):
#     def pipeline_counter(self):
#     def stage_name(self):
#     def stage_counter(self):
#     def url(self):
#     def stage(self):
#     def artifacts(self):
#     def properties(self):
# 
# Path: yagocd/resources/pipeline.py
# class PipelineManager(BaseManager):
# class PipelineEntity(BaseNode):
# class PipelineInstance(BaseNode):
#     GROUPS_RESOURCE_PATH = '{base_api}/config/pipeline_groups'
#     RESOURCE_PATH = '{base_api}/pipelines/{name}'
#     VSM_RESOURCE_PATH = '{base_api}/pipelines/value_stream_map/{name}'
#     def __iter__(self):
#     def __getitem__(self, name):
#     def list(self):
#     def find(self, name):
#     def history(self, name, offset=0):
#     def full_history(self, name):
#     def last(self, name):
#     def get(self, name, counter):
#     def status(self, name):
#     def pause(self, name, cause):
#     def unpause(self, name):
#     def release_lock(self, name):
#     def schedule(self, name, materials=None, variables=None, secure_variables=None):
#     def schedule_with_instance(
#         self,
#         name,
#         materials=None,
#         variables=None,
#         secure_variables=None,
#         backoff=0.5,
#         max_tries=20
#     ):
#     def value_stream_map(self, name, counter):
#     def __init__(self, session, data, group=None):
#     def __iter__(self):
#     def __getitem__(self, counter):
#     def group(self):
#     def get_url(server_url, pipeline_name):
#     def url(self):
#     def config(self):
#     def history(self, offset=0):
#     def full_history(self):
#     def last(self):
#     def get(self, counter):
#     def status(self):
#     def pause(self, cause):
#     def unpause(self):
#     def release_lock(self):
#     def schedule(self, materials=None, variables=None, secure_variables=None):
#     def schedule_with_instance(
#         self,
#         materials=None,
#         variables=None,
#         secure_variables=None,
#         backoff=0.5,
#         max_tries=20
#     ):
#     def value_stream_map(self, counter):
#     def __init__(self, session, data):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def url(self):
#     def pipeline_url(self):
#     def stages(self):
#     def stage(self, name):
#     def value_stream_map(self):
#     def config(self):
# 
# Path: yagocd/resources/stage.py
# class StageManager(BaseManager, RequireParamMixin):
# class StageInstance(Base):
# class StageResult(object):
# class StageState(object):
#     RUN_RESOURCE_PATH = '{base_api}/run/{pipeline_name}/{pipeline_counter}/{stage_name}'
#     RESOURCE_PATH = '{base_api}/stages/{pipeline_name}/{stage_name}'
#     def __init__(
#         self,
#         session,
#         pipeline_name=None,
#         pipeline_counter=None,
#         stage_name=None,
#         stage_counter=None,
#     ):
#     def run(self, pipeline_name=None, pipeline_counter=None, stage_name=None):
#     def cancel(self, pipeline_name=None, stage_name=None):
#     def get(
#         self,
#         pipeline_name=None,
#         pipeline_counter=None,
#         stage_name=None,
#         stage_counter=None
#     ):
#     def history(self, pipeline_name=None, stage_name=None, offset=0):
#     def full_history(self, pipeline_name=None, stage_name=None):
#     def last(self, pipeline_name=None, stage_name=None):
#     def __init__(self, session, data, pipeline):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def url(self):
#     def pipeline_name(self):
#     def pipeline_counter(self):
#     def stage_name(self):
#     def stage_counter(self):
#     def pipeline(self):
#     def cancel(self):
#     def jobs(self):
#     def job(self, name):


import re
import mock
import pytest
from yagocd.resources import job, pipeline, stage
            pipeline_name=stage_instance_from_pipeline.pipeline_name,
            stage_name=stage_instance_from_pipeline.stage_name
        )

    @mock.patch('yagocd.resources.stage.StageManager.cancel')
    def test_cancel_call_from_stage(self, cancel_mock, stage_instance_from_stage_history):
        stage_instance_from_stage_history.cancel()
        cancel_mock.assert_called_with(
            pipeline_name=stage_instance_from_stage_history.pipeline_name,
            stage_name=stage_instance_from_stage_history.stage_name
        )

    def test_jobs_return_type_from_pipeline(self, stage_instance_from_pipeline):
        jobs = stage_instance_from_pipeline.jobs()
        assert all(isinstance(j, job.JobInstance) for j in jobs)

    def test_jobs_return_type_from_stage(self, stage_instance_from_stage_history):
        jobs = stage_instance_from_stage_history.jobs()
        assert all(isinstance(j, job.JobInstance) for j in jobs)

    @mock.patch('yagocd.resources.stage.StageInstance.jobs')
    def test_job(self, stages_mock, stage_instance_from_pipeline):
        foo = mock.MagicMock()
        foo.data.name = 'foo'
        bar = mock.MagicMock()
        bar.data.name = 'bar'
        baz = mock.MagicMock()
        baz.data.name = 'baz'
        stages_mock.return_value = [foo, bar, baz]


# Path: yagocd/resources/job.py
# class JobManager(BaseManager, RequireParamMixin):
# class JobInstance(Base):
#     RESOURCE_PATH = '{base_api}/jobs'
#     def __init__(
#         self,
#         session,
#         pipeline_name=None,
#         stage_name=None,
#         job_name=None,
#     ):
#     def scheduled(self):
#     def history(self, pipeline_name=None, stage_name=None, job_name=None, offset=0):
#     def __init__(self, session, data, stage):
#     def pipeline_name(self):
#     def pipeline_counter(self):
#     def stage_name(self):
#     def stage_counter(self):
#     def url(self):
#     def stage(self):
#     def artifacts(self):
#     def properties(self):
# 
# Path: yagocd/resources/pipeline.py
# class PipelineManager(BaseManager):
# class PipelineEntity(BaseNode):
# class PipelineInstance(BaseNode):
#     GROUPS_RESOURCE_PATH = '{base_api}/config/pipeline_groups'
#     RESOURCE_PATH = '{base_api}/pipelines/{name}'
#     VSM_RESOURCE_PATH = '{base_api}/pipelines/value_stream_map/{name}'
#     def __iter__(self):
#     def __getitem__(self, name):
#     def list(self):
#     def find(self, name):
#     def history(self, name, offset=0):
#     def full_history(self, name):
#     def last(self, name):
#     def get(self, name, counter):
#     def status(self, name):
#     def pause(self, name, cause):
#     def unpause(self, name):
#     def release_lock(self, name):
#     def schedule(self, name, materials=None, variables=None, secure_variables=None):
#     def schedule_with_instance(
#         self,
#         name,
#         materials=None,
#         variables=None,
#         secure_variables=None,
#         backoff=0.5,
#         max_tries=20
#     ):
#     def value_stream_map(self, name, counter):
#     def __init__(self, session, data, group=None):
#     def __iter__(self):
#     def __getitem__(self, counter):
#     def group(self):
#     def get_url(server_url, pipeline_name):
#     def url(self):
#     def config(self):
#     def history(self, offset=0):
#     def full_history(self):
#     def last(self):
#     def get(self, counter):
#     def status(self):
#     def pause(self, cause):
#     def unpause(self):
#     def release_lock(self):
#     def schedule(self, materials=None, variables=None, secure_variables=None):
#     def schedule_with_instance(
#         self,
#         materials=None,
#         variables=None,
#         secure_variables=None,
#         backoff=0.5,
#         max_tries=20
#     ):
#     def value_stream_map(self, counter):
#     def __init__(self, session, data):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def url(self):
#     def pipeline_url(self):
#     def stages(self):
#     def stage(self, name):
#     def value_stream_map(self):
#     def config(self):
# 
# Path: yagocd/resources/stage.py
# class StageManager(BaseManager, RequireParamMixin):
# class StageInstance(Base):
# class StageResult(object):
# class StageState(object):
#     RUN_RESOURCE_PATH = '{base_api}/run/{pipeline_name}/{pipeline_counter}/{stage_name}'
#     RESOURCE_PATH = '{base_api}/stages/{pipeline_name}/{stage_name}'
#     def __init__(
#         self,
#         session,
#         pipeline_name=None,
#         pipeline_counter=None,
#         stage_name=None,
#         stage_counter=None,
#     ):
#     def run(self, pipeline_name=None, pipeline_counter=None, stage_name=None):
#     def cancel(self, pipeline_name=None, stage_name=None):
#     def get(
#         self,
#         pipeline_name=None,
#         pipeline_counter=None,
#         stage_name=None,
#         stage_counter=None
#     ):
#     def history(self, pipeline_name=None, stage_name=None, offset=0):
#     def full_history(self, pipeline_name=None, stage_name=None):
#     def last(self, pipeline_name=None, stage_name=None):
#     def __init__(self, session, data, pipeline):
#     def __iter__(self):
#     def __getitem__(self, name):
#     def url(self):
#     def pipeline_name(self):
#     def pipeline_counter(self):
#     def stage_name(self):
#     def stage_counter(self):
#     def pipeline(self):
#     def cancel(self):
#     def jobs(self):
#     def job(self, name):


# Path: tests/test_stage_instance.py
import re
import mock
import pytest
from yagocd.resources import job, pipeline, stage

            pipeline_name=stage_instance_from_pipeline.pipeline_name,
            stage_name=stage_instance_from_pipeline.stage_name
        )

    @mock.patch('yagocd.resources.stage.StageManager.cancel')
    def test_cancel_call_from_stage(self, cancel_mock, stage_instance_from_stage_history):
        stage_instance_from_stage_history.cancel()
        cancel_mock.assert_called_with(
            pipeline_name=stage_instance_from_stage_history.pipeline_name,
            stage_name=stage_instance_from_stage_history.stage_name
        )

    def test_jobs_return_type_from_pipeline(self, stage_instance_from_pipeline):
        jobs = stage_instance_from_pipeline.jobs()
        assert all(isinstance(j, job.JobInstance) for j in jobs)

    def test_jobs_return_type_from_stage(self, stage_instance_from_stage_history):
        jobs = stage_instance_from_stage_history.jobs()
        assert all(isinstance(j, job.JobInstance) for j in jobs)

    @mock.patch('yagocd.resources.stage.StageInstance.jobs')
    def test_job(self, stages_mock, stage_instance_from_pipeline):
        foo = mock.MagicMock()
        foo.data.name = 'foo'
        bar = mock.MagicMock()
        bar.data.name = 'bar'
        baz = mock.MagicMock()
        baz.data.name = 'baz'
        stages_mock.return_value = [foo, bar, baz]


        result = stage_instance_from_pipeline.job(name='baz')