Esempio n. 1
0
def test_get_analysis_code_reuse_command_success(requests_mock):
    # Arrange
    analysis_id = 'analysis_id'
    sub_analysis_id = 'sub_analysis_id'
    _setup_access_token(requests_mock)
    requests_mock.get(
        f'{full_url}/analyses/{analysis_id}/sub-analyses/{sub_analysis_id}/code-reuse',
        json={
            'families': [{
                'family_id': '123',
                'family_name': 'Name',
                'reused_gene_count': 123
            }],
            'unique_gene_count':
            0
        })

    args = dict(analysis_id=analysis_id, sub_analysis_id=sub_analysis_id)

    # Act
    command_results = get_analysis_code_reuse_command(intezer_api, args)

    # Assert
    outputs = command_results.outputs[
        'Intezer.Analysis(obj.RootAnalysis == val.ID).SubAnalyses(obj.ID == val.ID)']
    assert outputs['ID'] == sub_analysis_id
    assert outputs['RootAnalysis'] == analysis_id
    assert len(outputs['CodeReuseFamilies']) == 1
    assert 'CodeReuse' in outputs
Esempio n. 2
0
def test_get_analysis_code_reuse_command_no_code_reuse(requests_mock):
    # Arrange
    analysis_id = 'analysis_id'
    sub_analysis_id = 'sub_analysis_id'
    _setup_access_token(requests_mock)
    requests_mock.get(
        f'{full_url}/analyses/{analysis_id}/sub-analyses/{sub_analysis_id}/code-reuse',
        status_code=HTTPStatus.CONFLICT)

    args = dict(analysis_id=analysis_id, sub_analysis_id=sub_analysis_id)

    # Act
    command_results = get_analysis_code_reuse_command(intezer_api, args)

    # Assert
    assert command_results.readable_output == 'No code reuse for this analysis'
Esempio n. 3
0
def test_get_analysis_code_reuse_command_analysis_doesnt_exist(requests_mock):
    # Arrange
    analysis_id = 'analysis_id'
    sub_analysis_id = 'sub_analysis_id'
    _setup_access_token(requests_mock)
    requests_mock.get(
        f'{full_url}/analyses/{analysis_id}/sub-analyses/{sub_analysis_id}/code-reuse',
        status_code=HTTPStatus.NOT_FOUND)

    args = dict(analysis_id=analysis_id, sub_analysis_id=sub_analysis_id)

    # Act
    command_results = get_analysis_code_reuse_command(intezer_api, args)

    # Assert
    assert command_results.readable_output == f'The Analysis {analysis_id} was not found on Intezer Analyze'