Coverage for tests/utils/keys_book.py: 97%
36 statements
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 19:49 +0000
« prev ^ index » next coverage.py v7.17.3, created at 2026-11-22 19:49 +0000
1from __future__ import annotations
2from configparser import ConfigParser
5class KeysBook:
6 """Test wallet keys book loaded from test configuration."""
8 private_view_key: str = ''
9 """Test wallet private view key."""
10 public_view_key: str = ''
11 """Test wallet public view key."""
12 private_spend_key: str = ''
13 """Test wallet private spend key."""
14 public_spend_key: str = ''
15 """Test wallet public spend key."""
16 invalid_private_view_key: str = ''
17 """An invalid private view key."""
18 invalid_public_view_key: str = ''
19 """An invalid public view key."""
20 invalid_private_spend_key: str = ''
21 """An invalid private spend key."""
22 invalid_public_spend_key: str = ''
23 """An invalid public spend key."""
24 seed: str = ''
25 """Test wallet seed."""
27 @classmethod
28 def parse(cls, parser: ConfigParser) -> KeysBook:
29 """
30 Parse test wallet keys book configuration.
32 :param ConfigParser parser: configuration parser.
33 :returns KeysBook: test wallet keys book configuration.
34 """
35 # check for keys section
36 if not parser.has_section('keys'):
37 raise Exception("Section [keys] not found")
38 # load configuration
39 book: KeysBook = cls()
40 book.private_view_key = parser.get('keys', 'private_view_key')
41 book.public_view_key = parser.get('keys', 'public_view_key')
42 book.private_spend_key = parser.get('keys', 'private_spend_key')
43 book.public_spend_key = parser.get('keys', 'public_spend_key')
44 book.invalid_private_view_key = parser.get('keys', 'invalid_private_view_key')
45 book.invalid_public_view_key = parser.get('keys', 'invalid_public_view_key')
46 book.invalid_private_spend_key = parser.get('keys', 'invalid_private_spend_key')
47 book.invalid_public_spend_key = parser.get('keys', 'invalid_public_spend_key')
48 book.seed = parser.get('keys', 'seed')
49 return book