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


import pytest
import tabun_api as api
import testutil
    import os
    import os
    import time
    import time
from tabun_api.compat import PY2
from testutil import UserTest, intercept, form_intercept, set_mock, as_guest, user
        os.getenv = old_getenv


def test_init_proxy_unknown():
    with pytest.raises(ValueError):
        UserTest(proxy='blablabla,localhost,9999')


def test_check_login(user):
    user.security_ls_key = None
    with pytest.raises(api.TabunError):
        user.check_login()


def test_ajax_hacking_attemp(set_mock, user):
    set_mock({'/ajax/': (None, {'data': b'Hacking attemp!'})})
    with pytest.raises(api.TabunResultError) as excinfo:
        user.ajax('/ajax/', {'a': 5})
    assert excinfo.value.message == 'Hacking attemp!'


def test_login_hacking_attemp(set_mock, user):
    set_mock({'/login/ajax-login': (None, {'data': b'Hacking attemp!'})})
    with pytest.raises(api.TabunResultError) as excinfo:
        user.login('test', '123456')
    assert excinfo.value.message == 'Hacking attemp!'


def test_build_request_internal(user):
    req = user.build_request('/blog/2.html')

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


# Path: test/test_user.py
import pytest
import tabun_api as api
import testutil
    import os
    import os
    import time
    import time
from tabun_api.compat import PY2
from testutil import UserTest, intercept, form_intercept, set_mock, as_guest, user

        os.getenv = old_getenv


def test_init_proxy_unknown():
    with pytest.raises(ValueError):
        UserTest(proxy='blablabla,localhost,9999')


def test_check_login(user):
    user.security_ls_key = None
    with pytest.raises(api.TabunError):
        user.check_login()


def test_ajax_hacking_attemp(set_mock, user):
    set_mock({'/ajax/': (None, {'data': b'Hacking attemp!'})})
    with pytest.raises(api.TabunResultError) as excinfo:
        user.ajax('/ajax/', {'a': 5})
    assert excinfo.value.message == 'Hacking attemp!'


def test_login_hacking_attemp(set_mock, user):
    set_mock({'/login/ajax-login': (None, {'data': b'Hacking attemp!'})})
    with pytest.raises(api.TabunResultError) as excinfo:
        user.login('test', '123456')
    assert excinfo.value.message == 'Hacking attemp!'


def test_build_request_internal(user):
    req = user.build_request('/blog/2.html')

    if PY2: