コード例 #1
0
def test_list_predictors(valid_simple_ml_predictor_data,
                         valid_expression_predictor_data,
                         basic_predictor_report_data):
    # Given
    session = FakeSession()
    collection = PredictorCollection(uuid.uuid4(), session)
    session.set_responses(
        {
            'entries':
            [valid_simple_ml_predictor_data, valid_expression_predictor_data],
            'next':
            ''
        }, basic_predictor_report_data, basic_predictor_report_data)

    # When
    predictors = list(collection.list(per_page=20))

    # Then
    expected_call = FakeCall(method='GET',
                             path='/projects/{}/modules'.format(
                                 collection.project_id),
                             params={
                                 'per_page': 20,
                                 'module_type': 'PREDICTOR'
                             })
    assert 3 == session.num_calls, session.calls  # This is a little strange, the report is fetched eagerly
    assert expected_call == session.calls[0]
    assert len(predictors) == 2
コード例 #2
0
def test_mark_predictor_invalid(valid_simple_ml_predictor_data, valid_predictor_report_data):
    # Given
    session = FakeSession()
    collection = PredictorCollection(uuid.uuid4(), session)
    predictor = SimpleMLPredictor.build(valid_simple_ml_predictor_data)
    session.set_responses(valid_simple_ml_predictor_data, valid_predictor_report_data)

    # When
    predictor.archived = False
    collection.update(predictor)

    # Then
    assert 1 == session.num_calls, session.calls

    first_call = session.calls[0]  # First call is the update
    assert first_call.method == 'PUT'
    assert first_call.path == '/projects/{}/modules/{}'.format(collection.project_id, predictor.uid)
    assert not first_call.json['archived']
コード例 #3
0
def test_list_workflows(basic_design_workflow_data,
                        basic_performance_workflow_data):
    #Given
    session = FakeSession()
    workflow_collection = WorkflowCollection(project_id=uuid.uuid4(),
                                             session=session)
    session.set_responses(
        {
            'entries': [basic_design_workflow_data],
            'next': ''
        },
        {
            'entries': [basic_performance_workflow_data],
            'next': ''
        },
    )

    # When
    workflows = list(workflow_collection.list(per_page=20))

    # Then
    expected_design_call = FakeCall(method='GET',
                                    path='/projects/{}/modules'.format(
                                        workflow_collection.project_id),
                                    params={
                                        'per_page': 20,
                                        'module_type': 'DESIGN_WORKFLOW'
                                    })
    expected_performance_call = FakeCall(
        method='GET',
        path='/projects/{}/modules'.format(workflow_collection.project_id),
        params={
            'per_page': 20,
            'module_type': 'PERFORMANCE_WORKFLOW'
        })
    assert 2 == session.num_calls
    assert expected_design_call == session.calls[0]
    assert expected_performance_call == session.calls[1]
    assert len(workflows) == 2
    assert isinstance(workflows[0], DesignWorkflow)
    assert isinstance(workflows[1], PerformanceWorkflow)