# 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
        '/': cfdata['cf_mock'],
        '/login/': cfdata['cf_mock'],
        cfdata['answer_url']: cfdata['cf_mock_solved'],
    })

    calls = {'page': 0, 'solve': 0}

    @intercept('/')
    @intercept('/login/')
    def get_page(data, headers):
        calls['page'] += 1

    @intercept(cfdata['answer_url'])
    def cf_solve(data, headers):
        calls['solve'] += 1
        set_mock({
            '/': 'index.html',
            '/login/': 'login.html',
        })

    user = UserTest(security_ls_key='N/A', session_id='abcdef9876543210abcdef9876543210', avoid_cf=True)
    user.extra_cookies.update({
        '__cfduid': cfdata['cookvalue1'],
        'cf_clearance': 'foobarblablablathisisoldcookie',
    })

    resp = user.urlopen('/')
    assert resp.code == 200
    user.update_userinfo(resp.read())


# 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

        '/': cfdata['cf_mock'],
        '/login/': cfdata['cf_mock'],
        cfdata['answer_url']: cfdata['cf_mock_solved'],
    })

    calls = {'page': 0, 'solve': 0}

    @intercept('/')
    @intercept('/login/')
    def get_page(data, headers):
        calls['page'] += 1

    @intercept(cfdata['answer_url'])
    def cf_solve(data, headers):
        calls['solve'] += 1
        set_mock({
            '/': 'index.html',
            '/login/': 'login.html',
        })

    user = UserTest(security_ls_key='N/A', session_id='abcdef9876543210abcdef9876543210', avoid_cf=True)
    user.extra_cookies.update({
        '__cfduid': cfdata['cookvalue1'],
        'cf_clearance': 'foobarblablablathisisoldcookie',
    })

    resp = user.urlopen('/')
    assert resp.code == 200
    user.update_userinfo(resp.read())


    assert calls == {'page': 2, 'solve': 1}