<commit_before>from flask import url_for


def test_add_translation(app, client):
    data = dict(
        word='sheep',
        ipa='sziip',
        translation='owca',
        from_language='en',
        into_language='pl',
    )
    resp = app.test_client().post(
        url_for('ajax.add_translation'),
        data=data,
        headers={'Content-Type': 'application/x-www-form-urlencoded'})
    assert resp.status_code == 200
    assert resp.json == dict(translation=dict(id=1, ipa='sziip', translation='owca', word='sheep'))<commit_msg>better test_add_translation<commit_after>from flask import url_for
from wordbook.domain.repo.translation import Repo
from wordbook.infra.models.translation import Translation


def test_add_translation(app, client):
    data = dict(
        word='sheep',
        ipa='sziip',
        translation='owca',
        from_language='en',
        into_language='pl',
    )
    resp = app.test_client().post(
        url_for('ajax.add_translation'),
        data=data,
        headers={'Content-Type': 'application/x-www-form-urlencoded'})
    assert resp.status_code == 200
    assert resp.json == dict(translation=dict(id=1, ipa='sziip', translation='owca', word='sheep'))
    repo = Repo()
    translation = repo.get(resp.json['translation']['id'])
    assert translation.translated == 'owca'
    assert translation.from_language == 'en'
    assert translation.word == 'sheep'
    assert translation.ipa == 'sziip'
    assert translation.into_language == 'pl'
{'fraction_non_alphanumeric': 0.14085447263017356, 'fraction_numerical': 0.0053404539385847796, 'mean_word_length': 3.4746268656716417, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '5981465', 'n_tokens_mistral': 466, 'n_tokens_neox': 454, 'n_words': 85}