File: test_latin1.py

package info (click to toggle)
gnome-keysign 1.3.0-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,460 kB
  • sloc: python: 5,143; xml: 126; makefile: 33; sh: 16
file content (75 lines) | stat: -rw-r--r-- 1,686 bytes parent folder | download | duplicates (4)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python

import logging
import sys, os

import gi
gi.require_version('Gtk', "3.0")
from gi.repository import Gtk, GLib


from keysign import gpgmeh
from keysign.KeyPresent import KeyPresentWidget
from keysign.keyconfirm import PreSignWidget
from keysign.keylistwidget import KeyListWidget


## We should unify this fixture related code somehow
log = logging.getLogger(__name__)
thisdir = os.path.dirname(os.path.realpath(__file__))
parentdir = os.path.join(thisdir, "..")


def get_fixture_dir(fixture=""):
    dname = os.path.join(thisdir, "fixtures", fixture)
    return dname


def get_fixture_file(fixture):
    fname = os.path.join(get_fixture_dir(), fixture)
    return fname


def read_fixture_file(fixture):
    fname = get_fixture_file(fixture)
    data = open(fname, 'rb').read()
    return data


def load_key(key):
    f = read_fixture_file(key)
    k = gpgmeh.openpgpkey_from_data(f)
    return k


def load_latin1_key():
    key = "seckey-latin1.asc"
    return load_key(key)


def _gui_test(widget):
    widget.show_all()
    GLib.timeout_add_seconds(2,  Gtk.main_quit)
    Gtk.main()


def test_kpw():
    """We had problems with non-UTF-8 UIDs and KPW. We try to load one"""
    key = load_latin1_key()
    log.info("Loaded %r", key)
    kpw = KeyPresentWidget(key=key, discovery_code="")
    _gui_test(kpw)


def test_psw():
    """We had problems with non UTF-8 UIDs and PSW. We try to load one"""
    key = load_latin1_key()
    psw = PreSignWidget(key=key)
    _gui_test(psw)


def test_klw():
    """We had problems with non UTF-8 UIDs and KLW. We try to load one"""
    key = load_latin1_key()
    klw = KeyListWidget(keys=[key])
    _gui_test(klw)