# Path: tabun_api/compat.py
# PY2 = sys.version_info.major == 2


import time
import json
import pytest
import tabun_api as api
from io import BytesIO
from tabun_api.compat import text, binary
from testutil import UserTest, load_file, form_intercept, set_mock, user, assert_data
        {'data': '{"newText": "тест2", "notice": null, "sMsgTitle": null, "sMsg": "Комментарий изменён", "bStateError": false}'.encode('utf-8')},
    )})

    @form_intercept('/ajax/comment/edit/')
    def edit_comment(data, headers):
        assert headers.get('content-type', '').startswith(b'multipart/form-data; boundary=-')

        assert data.get('security_ls_key') == [b'0123456789abcdef0123456789abcdef']
        assert data.get('idComment') == [b'777']
        assert data.get('newText') == ['тест2'.encode('utf-8')]
        assert data.get('setLock') == [b'0']

    assert user.edit_comment(777, 'тест2') == ('тест2', 'Комментарий изменён', None)


def test_edit_comment_error(form_intercept, set_mock, user):
    set_mock({'/ajax/comment/edit/': (
        None,
        {'data': '{"newText": "тест", "notice": null, "sMsgTitle": "Ошибка доступа", "sMsg": "Вы не можете изменять чужой комментарий, срок редактирования которого истёк", "bStateError": true}'.encode('utf-8')},
    )})

    @form_intercept('/ajax/comment/edit/')
    def edit_comment(data, headers):
        assert headers.get('content-type', '').startswith(b'multipart/form-data; boundary=-')

        assert data.get('security_ls_key') == [b'0123456789abcdef0123456789abcdef']
        assert data.get('idComment') == [b'777']
        assert data.get('newText') == ['тест2'.encode('utf-8')]
        assert data.get('setLock') == [b'0']


# Path: tabun_api/compat.py
# PY2 = sys.version_info.major == 2


# Path: test/test_comments.py
import time
import json
import pytest
import tabun_api as api
from io import BytesIO
from tabun_api.compat import text, binary
from testutil import UserTest, load_file, form_intercept, set_mock, user, assert_data

        {'data': '{"newText": "тест2", "notice": null, "sMsgTitle": null, "sMsg": "Комментарий изменён", "bStateError": false}'.encode('utf-8')},
    )})

    @form_intercept('/ajax/comment/edit/')
    def edit_comment(data, headers):
        assert headers.get('content-type', '').startswith(b'multipart/form-data; boundary=-')

        assert data.get('security_ls_key') == [b'0123456789abcdef0123456789abcdef']
        assert data.get('idComment') == [b'777']
        assert data.get('newText') == ['тест2'.encode('utf-8')]
        assert data.get('setLock') == [b'0']

    assert user.edit_comment(777, 'тест2') == ('тест2', 'Комментарий изменён', None)


def test_edit_comment_error(form_intercept, set_mock, user):
    set_mock({'/ajax/comment/edit/': (
        None,
        {'data': '{"newText": "тест", "notice": null, "sMsgTitle": "Ошибка доступа", "sMsg": "Вы не можете изменять чужой комментарий, срок редактирования которого истёк", "bStateError": true}'.encode('utf-8')},
    )})

    @form_intercept('/ajax/comment/edit/')
    def edit_comment(data, headers):
        assert headers.get('content-type', '').startswith(b'multipart/form-data; boundary=-')

        assert data.get('security_ls_key') == [b'0123456789abcdef0123456789abcdef']
        assert data.get('idComment') == [b'777']
        assert data.get('newText') == ['тест2'.encode('utf-8')]
        assert data.get('setLock') == [b'0']


    with pytest.raises(api.TabunResultError) as excinfo: