Exemplo n.º 1
0
    def test_load_artifact_from_archive_with_mock_provenance(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()
        mock_provenance = self.MockProvenance()

        pipeline_context.provenance = mock_provenance
        pipeline_context.load_artifact_from_archive(mock_archive)

        self.assertEqual(mock_archive, mock_provenance.archiver)
Exemplo n.º 2
0
    def test_fill_provenance(self):
        from foundations_contrib.config_manager import ConfigManager

        self.config_manager = ConfigManager()
        pipeline_context = PipelineContext()

        self.config_manager["other_world"] = "aliens"

        pipeline_context.fill_provenance(self.config_manager)
        self.assertEqual(pipeline_context.provenance.config["other_world"], "aliens")
Exemplo n.º 3
0
    def setUp(self):
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.pipeline import Pipeline

        self._context = PipelineContext()
        self._pipeline = Pipeline(self._context)
        self._stage = self._pipeline.stage(self._method)
Exemplo n.º 4
0
    def setUp(self):
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self._pipeline = Pipeline(self._pipeline_context)
        self._context = FoundationsContext(self._pipeline)
Exemplo n.º 5
0
    def setUp(self):
        from foundations_contrib.global_state import redis_connection
        from foundations_contrib.global_state import message_router
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.pipeline import Pipeline
        import faker

        self._redis = redis_connection
        self._redis.flushall()
        self._faker = faker.Faker()

        self._pipeline_context = PipelineContext()

        self._project_name = self._str_random_uuid()
        self._pipeline_context.provenance.project_name = self._project_name

        self._job_id = self._str_random_uuid()
        self._pipeline_context.file_name = self._job_id

        self._user = self._random_name()
        self._pipeline_context.provenance.user_name = self._user

        self._pipeline = Pipeline(self._pipeline_context)

        self._message_router = message_router
    def setUpClass(klass):
        from foundations_contrib.global_state import message_router
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext

        klass._message_router = message_router
        klass._pipeline_context = PipelineContext()
        klass._pipeline = Pipeline(klass._pipeline_context)
    def test_pipeline_context_wrapper_returns_pipeline_context(self):
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.pipeline_context_wrapper import PipelineContextWrapper

        pipeline_context = PipelineContext()
        pipeline_context_wrapper = PipelineContextWrapper(pipeline_context)
        self.assertEqual(pipeline_context,
                         pipeline_context_wrapper.pipeline_context())
Exemplo n.º 8
0
    def set_up(self):
        import fakeredis
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self._pipeline = Pipeline(self._pipeline_context)
        self.patch('foundations_rest_api.global_state.redis_connection',
                   fakeredis.FakeRedis())
Exemplo n.º 9
0
def _create_foundations_context():
    from foundations_internal.pipeline_context import PipelineContext
    from foundations_internal.pipeline import Pipeline
    from foundations_internal.foundations_context import FoundationsContext

    _pipeline_context = PipelineContext()
    _pipeline = Pipeline(_pipeline_context)

    return FoundationsContext(_pipeline)
Exemplo n.º 10
0
    def set_up(self):
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self.mock_current_foundations_context.pipeline_context.return_value = self._pipeline_context

        self._message_router = self.MockMessageRouter()
        self._logger = GlobalMetricLogger(self._message_router)

        self._pipeline_context.file_name = None
        self._pipeline_context.provenance.project_name = self.fake_project_name
Exemplo n.º 11
0
    def setUp(self):
        from foundations_internal.pipeline_context import PipelineContext

        self.route_name = None
        self.message = None

        self._pipeline_context = PipelineContext()
        self._pipeline_context.file_name = 'some_project'
        self._router = Mock()
        self._router.push_message.side_effect = self._push_message
        self._producer = RunJob(self._router, self._pipeline_context)
Exemplo n.º 12
0
    def test_load_artifact_from_archive_fully_loaded(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()
        mock_provenance = self.MockProvenance()

        pipeline_context.mark_fully_loaded()
        pipeline_context.provenance = mock_provenance
        pipeline_context.load_artifact_from_archive(mock_archive)

        self.assertEqual(0, mock_provenance.load_artifact_counter)
Exemplo n.º 13
0
    def set_up(self):
        from foundations_internal.pipeline_context import PipelineContext

        self._pipeline_context = PipelineContext()
        self._pipeline_context.file_name = None
        self._pipeline_context.provenance.project_name = self.project_name

        self.foundations_context.pipeline_context.return_value = self._pipeline_context

        self.foundations_context.pipeline_context().provenance.annotations = (
            self.provenance_annotations)
        self.redis.flushall()
Exemplo n.º 14
0
    def test_save_uses_save_method_on_result_saver(self):
        pipeline_context = PipelineContext()
        pipeline_context.file_name = self.job_id
        mock_result_saver = self.MockResultSaver()

        pipeline_context.save(mock_result_saver)
        self.assertEqual(mock_result_saver.file_name, pipeline_context.file_name)
        self.assertEqual(mock_result_saver.context, pipeline_context._context())
Exemplo n.º 15
0
    def setUp(self):
        from foundations_internal.pipeline_context import PipelineContext

        self.route_name = None
        self.message = None

        self._pipeline_context = PipelineContext()
        self._pipeline_context.file_name = 'some_project'
        self._router = Mock()
        self._router.push_message.side_effect = self._push_message
        self._error_information = {'type': None,
                                   'exception': None, 'traceback': []}
        self._producer = FailedJob(
            self._router, self._pipeline_context, self._error_information)
Exemplo n.º 16
0
def cleanup():
    import shutil
    from os import getcwd, remove
    from os.path import isdir
    from glob import glob
    from foundations_contrib.global_state import redis_connection, foundations_job
    from foundations_internal.pipeline_context import PipelineContext
    from foundations_internal.pipeline import Pipeline

    tmp_dir = getcwd() + '/foundations_home/job_data'
    if isdir(tmp_dir):
        shutil.rmtree(tmp_dir)

    for file in glob('*.tgz'):
        remove(file)

    pipeline_context = PipelineContext()
    pipeline = Pipeline(pipeline_context)
    foundations_job._pipeline = pipeline
Exemplo n.º 17
0
def cleanup():
    import shutil
    from os import getcwd, remove
    from os.path import isdir
    from glob import glob
    from foundations_rest_api.global_state import redis_connection
    from foundations_contrib.global_state import foundations_context
    from foundations_internal.pipeline_context import PipelineContext
    from foundations_internal.pipeline import Pipeline

    tmp_dir = getcwd() + '/tmp'
    if isdir(tmp_dir):
        shutil.rmtree(tmp_dir)

    for file in glob('*.tgz'):
        remove(file)

    redis_connection.flushall()

    pipeline_context = PipelineContext()
    pipeline = Pipeline(pipeline_context)
    foundations_context._pipeline = pipeline
Exemplo n.º 18
0
    def setUp(self):
        from foundations_contrib.config_manager import ConfigManager
        from foundations_internal.deployment_manager import DeploymentManager
        from foundations_internal.pipeline import Pipeline
        from foundations_internal.pipeline_context import PipelineContext
        from foundations_internal.foundations_context import FoundationsContext

        self._listing = self.MockListing()

        self._config = ConfigManager()
        self._config["deployment_implementation"] = {
            "deployment_type": self.MockDeployment
        }

        self._config["project_listing_implementation"] = {
            "project_listing_type": self._mock_listing,
        }

        self._deployment_manager = DeploymentManager(self._config)

        self._pipeline_context = PipelineContext()
        self._pipeline = Pipeline(self._pipeline_context)
        self._foundations_context = FoundationsContext(self._pipeline)
Exemplo n.º 19
0
    def test_load_job_source_from_archive(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()

        pipeline_context.load_job_source_from_archive(mock_archive)
Exemplo n.º 20
0
    def test_load_artifact_from_archive(self):
        pipeline_context = PipelineContext()
        mock_archive = self.MockArchive()

        pipeline_context.load_artifact_from_archive(mock_archive)
Exemplo n.º 21
0
 def pipeline_context(self):
     from foundations_internal.pipeline_context import PipelineContext
     return PipelineContext()
Exemplo n.º 22
0
 def pipeline_context(self):
     return PipelineContext()