<commit_before>import pytest
pytestmark = [pytest.mark.working, pytest.mark.schema]


@pytest.fixture
def drug_treatment(testapp, lab, award):
    item = {
        'award': award['@id'],
        'lab': lab['@id'],
        'chemical': 'Drug',
    }
    return testapp.post_json('/treatment_chemical', item).json['@graph'][0]


def test_calculated_chemical_treatment_display_title(testapp, drug_treatment):
    # import pdb; pdb.set_trace()
    assert drug_treatment['display_title'] == 'Drug treatment'
    res = testapp.patch_json(
        drug_treatment['@id'],
        {'concentration': 3.5, 'concentration_units': 'M'})
    assert res.json['@graph'][0]['display_title'] == 'Drug treatment (3.5 M)'
    res = testapp.patch_json(
        drug_treatment['@id'],
        {'duration': 3.5, 'duration_units': 'hour'})
    assert res.json['@graph'][0]['display_title'] == 'Drug treatment (3.5 M, 3.5h)'
    res = testapp.patch_json(drug_treatment['@id'], {'temperature': 3.5})
    assert res.json['@graph'][0]['display_title'] == 'Drug treatment (3.5 M, 3.5h at 3.5°C)'
<commit_msg>Added test for treatment_agent display_title in test_types_treatment.py<commit_after>import pytest
pytestmark = [pytest.mark.working, pytest.mark.schema]


@pytest.fixture
def drug_treatment(testapp, lab, award):
    item = {
        'award': award['@id'],
        'lab': lab['@id'],
        'treatment_type': 'Chemical',
        'chemical': 'Drug',
    }
    return testapp.post_json('/treatment_chemical', item).json['@graph'][0]


@pytest.fixture
def heatshock_treatment(testapp, lab, award):
    item = {
        'award': award['@id'],
        'lab': lab['@id'],
        'treatment_type': 'Heat Shock',
    }
    return testapp.post_json('/treatment_agent', item).json['@graph'][0]


def test_calculated_chemical_treatment_display_title(testapp, heatshock_treatment):
    # import pdb; pdb.set_trace()
    assert heatshock_treatment['display_title'] == 'Heat Shock'
    res = testapp.patch_json(
        heatshock_treatment['@id'],
        {'duration': 3.5, 'duration_units': 'hour'})
    assert res.json['@graph'][0]['display_title'] == 'Heat Shock (3.5h)'
    res = testapp.patch_json(heatshock_treatment['@id'], {'temperature': 42})
    assert res.json['@graph'][0]['display_title'] == 'Heat Shock (3.5h at 42°C)'


def test_calculated_agent_treatment_display_title(testapp, drug_treatment):
    # import pdb; pdb.set_trace()
    assert drug_treatment['display_title'] == 'Drug treatment'
    res = testapp.patch_json(
        drug_treatment['@id'],
        {'concentration': 3.5, 'concentration_units': 'M'})
    assert res.json['@graph'][0]['display_title'] == 'Drug treatment (3.5 M)'
    res = testapp.patch_json(
        drug_treatment['@id'],
        {'duration': 3.5, 'duration_units': 'hour'})
    assert res.json['@graph'][0]['display_title'] == 'Drug treatment (3.5 M, 3.5h)'
    res = testapp.patch_json(drug_treatment['@id'], {'temperature': 3.5})
    assert res.json['@graph'][0]['display_title'] == 'Drug treatment (3.5 M, 3.5h at 3.5°C)'

{'fraction_non_alphanumeric': 0.18071099407504937, 'fraction_numerical': 0.018762343647136272, 'mean_word_length': 4.168367346938775, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6070426', 'n_tokens_mistral': 1135, 'n_tokens_neox': 1044, 'n_words': 197}