mirror of
https://github.com/jrnl-org/jrnl.git
synced 2025-05-10 16:48:31 +02:00
Fix Keyring tests
This commit is contained in:
parent
69fc08f6f3
commit
bdc9dc598d
3 changed files with 23 additions and 2 deletions
|
@ -5,11 +5,32 @@ from behave import given, when, then
|
||||||
from jrnl import cli, install, Journal, util
|
from jrnl import cli, install, Journal, util
|
||||||
from jrnl import __version__
|
from jrnl import __version__
|
||||||
from dateutil import parser as date_parser
|
from dateutil import parser as date_parser
|
||||||
|
from collections import defaultdict
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
import yaml
|
import yaml
|
||||||
import keyring
|
import keyring
|
||||||
keyring.set_keyring(keyring.backends.file.PlaintextKeyring())
|
|
||||||
|
|
||||||
|
class TestKeyring(keyring.backend.KeyringBackend):
|
||||||
|
"""A test keyring that just stores its valies in a hash
|
||||||
|
"""
|
||||||
|
priority = 1
|
||||||
|
keys = defaultdict(dict)
|
||||||
|
|
||||||
|
def set_password(self, servicename, username, password):
|
||||||
|
self.keys[servicename][username] = password
|
||||||
|
|
||||||
|
def get_password(self, servicename, username):
|
||||||
|
return self.keys[servicename].get(username)
|
||||||
|
|
||||||
|
def delete_password(self, servicename, username, password):
|
||||||
|
self.keys[servicename][username] = None
|
||||||
|
|
||||||
|
# set the keyring for keyring lib
|
||||||
|
keyring.set_keyring(TestKeyring())
|
||||||
|
|
||||||
|
|
||||||
try:
|
try:
|
||||||
from io import StringIO
|
from io import StringIO
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
|
@ -21,6 +21,7 @@ import sys
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
logging.getLogger("keyring.backend").setLevel(logging.ERROR)
|
||||||
|
|
||||||
|
|
||||||
def parse_args(args=None):
|
def parse_args(args=None):
|
||||||
|
|
|
@ -29,7 +29,6 @@ class Exporter(object):
|
||||||
|
|
||||||
def export_journal(self, journal):
|
def export_journal(self, journal):
|
||||||
"""Returns a unicode representation of an entire journal."""
|
"""Returns a unicode representation of an entire journal."""
|
||||||
print("EXPORTING")
|
|
||||||
return self.template.render_block("journal", **self._get_vars(journal))
|
return self.template.render_block("journal", **self._get_vars(journal))
|
||||||
|
|
||||||
def write_file(self, journal, path):
|
def write_file(self, journal, path):
|
||||||
|
|
Loading…
Add table
Reference in a new issue