Exemplo n.º 1
0
def test_process_bundle(mock_input_files, mock_resolve, mock_apply,
                        mock_retrieve):
    project = Project(id=4)
    project.save()

    pipeline = Pipeline(project=project)
    pipeline.save()

    stage_1 = PipelineStage(operation='noop',
                            pipeline=pipeline,
                            sort_order=1,
                            config={})
    stage_1.save()

    stage_2 = PipelineStage(operation='noop',
                            select_images=['blue'],
                            pipeline=pipeline,
                            sort_order=2,
                            config={})
    stage_2.save()

    request = ImageryRequest(adapter_name='dummy',
                             pipeline=pipeline,
                             project=project)
    request.save()

    bundle = JobBundle(id=3, total_stages=2)
    bundle.imagery_request = request
    bundle.pipeline = pipeline
    bundle.save()

    tasks.process_bundle(3)

    assert (mock_apply.call_count == 2)
    second_method_call = mock_apply.call_args_list[1]
    arguments = second_method_call[0]
    file_list = arguments[0]
    assert str.endswith(file_list[0], '/theia/1_noop/input_file')

    mock_retrieve.assert_called_once()
Exemplo n.º 2
0
    def test_from_requested_scene(self, mockCreate):
        project = Project(id=7)
        pipeline = Pipeline(project=project)
        request = ImageryRequest(pipeline=pipeline, project=project)
        scene = RequestedScene(imagery_request=request,
                               scene_entity_id='entity id')
        bundle = JobBundle.objects.from_requested_scene(scene)

        mockCreate.assert_called_once()
        mockCreate.assert_called_once_with(imagery_request=request,
                                           pipeline=pipeline,
                                           requested_scene=scene,
                                           scene_entity_id='entity id',
                                           total_stages=0)
Exemplo n.º 3
0
    def test_apply_multiple(self, mockAdd, mockCreate, mockGet, mockConnect,
                            mockGetName, *args):
        project = Project(id=8)
        pipeline = Pipeline(project=project, multiple_subject_sets=True)
        bundle = JobBundle(pipeline=pipeline)

        operation = UploadSubject(bundle)
        operation.apply(['some_file'])

        mockConnect.assert_called_once()
        mockGetName.assert_called_once()
        mockGet.assert_called_once_with(bundle, 8, 'bundle name')
        mockCreate.assert_called_once_with(8, 'some_file')
        mockAdd.assert_called_once_with(mockCreate.return_value)
Exemplo n.º 4
0
    def test_apply_single(self, mockOpen, mockAdd, mockCreate, mockGet,
                          mockGetName, mockIncludeMetadata, *args):
        project = Project(id=8)
        pipeline = Pipeline(project=project)
        bundle = JobBundle(pipeline=pipeline)

        operation = UploadSubject(bundle)
        operation.apply(['some_file'])

        mockOpen.assert_called_once()
        mockGetName.assert_called_once()
        mockGet.assert_called_once_with(pipeline, 8, 'pipeline name')
        mockCreate.assert_called_once_with(8, 'some_file', metadata={})
        mockAdd.assert_called_once_with(mockCreate.return_value)
Exemplo n.º 5
0
def test_process_bundle(mock_resolve, mock_apply, mock_save, mock_get,
                        mock_retrieve):
    project = Project()
    pipeline = Pipeline(project=project)
    stage_1 = PipelineStage(operation='noop')
    stage_2 = PipelineStage(operation='noop', select_images=['blue'])
    request = ImageryRequest(adapter_name='dummy', pipeline=pipeline)

    with patch('theia.api.models.Pipeline.get_stages',
               return_value=[stage_1, stage_2]) as mockStages:
        bundle = mock_get.return_value
        bundle.imagery_request = request
        bundle.pipeline = pipeline

        tasks.process_bundle(3)

        assert (mock_save.call_count == 2)

        assert (mock_apply.call_count == 2)
        mock_apply.assert_called_with(['blue_resolved'])

        mock_resolve.assert_called_with(ANY, stage_2, bundle, 'blue')
        mock_retrieve.assert_called_once()
Exemplo n.º 6
0
 def test____str__(self):
     project = Project(name='foo')
     assert (project.__str__() == 'foo')
Exemplo n.º 7
0
 def test___str__(self):
     project = Project(name='proj')
     pipeline = Pipeline(name='pipe', project=project)
     assert(pipeline.__str__()=='proj | pipe')