File: test_token.py

package info (click to toggle)
python-pywebview 3.3.5%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, sid
  • size: 29,536 kB
  • sloc: python: 5,703; javascript: 888; cs: 130; sh: 55; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 797 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import webview
from .util import run_test


def test_token():
    window = webview.create_window('Token test')
    run_test(webview, window, token_test)

def test_persistance():
    window = webview.create_window('Token persistance test')
    run_test(webview, window, persistance_test)


def token_test(window):
    token = window.evaluate_js('window.pywebview.token')
    assert token is not None
    assert len(token) > 0


def persistance_test(window):
    token1 = window.evaluate_js('pywebview.token')
    assert token1 is not None

    window.load_html('<div>new HTML</div>')
    token2 = window.evaluate_js('pywebview.token')
    assert token1 == token2

    window.load_url('https://example.org')
    token3 = window.evaluate_js('pywebview.token')
    assert token1 == token2 == token3