<commit_before>import pytest
import rules

from adhocracy4.test import helpers


@pytest.mark.django_db
def test_get_change_perm(rf, idea_factory):
    obj = idea_factory()
    request = rf.get('/')
    template = ('{% load item_tags %}'
                '{% get_item_view_permission obj as view_perm %}'
                '{% get_item_add_permission obj as add_perm %}'
                '{% get_item_change_permission obj as change_perm %}'
                '{% get_item_delete_permission obj as delete_perm %}'
                '{{ view_perm }}'
                '{{ add_perm }}'
                '{{ change_perm }}'
                '{{ delete_perm }}')
    context = {'request': request, 'obj': obj}
    helpers.render_template(template, context)

    assert 'meinberlin_ideas.view_idea' == context['view_perm']
    assert rules.perm_exists(context['view_perm'])
    assert 'meinberlin_ideas.add_idea' == context['add_perm']
    assert rules.perm_exists(context['add_perm'])
    assert 'meinberlin_ideas.change_idea' == context['change_perm']
    assert rules.perm_exists(context['change_perm'])
    assert 'meinberlin_ideas.delete_idea' == context['delete_perm']<commit_msg>add test for get_item_url<commit_after>import pytest
import rules

from adhocracy4.test import helpers


@pytest.mark.django_db
def test_get_change_perm(rf, idea_factory):
    obj = idea_factory()
    request = rf.get('/')
    template = ('{% load item_tags %}'
                '{% get_item_view_permission obj as view_perm %}'
                '{% get_item_add_permission obj as add_perm %}'
                '{% get_item_change_permission obj as change_perm %}'
                '{% get_item_delete_permission obj as delete_perm %}'
                '{{ view_perm }}'
                '{{ add_perm }}'
                '{{ change_perm }}'
                '{{ delete_perm }}')
    context = {'request': request, 'obj': obj}
    helpers.render_template(template, context)

    assert 'meinberlin_ideas.view_idea' == context['view_perm']
    assert rules.perm_exists(context['view_perm'])
    assert 'meinberlin_ideas.add_idea' == context['add_perm']
    assert rules.perm_exists(context['add_perm'])
    assert 'meinberlin_ideas.change_idea' == context['change_perm']
    assert rules.perm_exists(context['change_perm'])
    assert 'meinberlin_ideas.delete_idea' == context['delete_perm']


@pytest.mark.django_db
def test_get_item_url(rf, idea_factory):
    obj = idea_factory()
    request = rf.get('/')
    template = ('{% load item_tags %}'
                '{% get_item_update_url obj as update_url %}'
                '{% get_item_delete_url obj as delete_url %}'
                '{{ update_url }}'
                '{{ delete_url }}')
    context = {'request': request, 'obj': obj}
    helpers.render_template(template, context)

    assert ('/ideas/{}-{}/update/'.format(obj.created.year,
            '{:05d}'.format(obj.pk)) == context['update_url'])
    assert ('/ideas/{}-{}/delete/'.format(obj.created.year,
            '{:05d}'.format(obj.pk)) == context['delete_url'])
{'fraction_non_alphanumeric': 0.14126149802890933, 'fraction_numerical': 0.0019710906701708277, 'mean_word_length': 2.985602094240838, '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': '4096728', 'n_tokens_mistral': 977, 'n_tokens_neox': 948, 'n_words': 166}