|
|
@@ -773,13 +773,18 @@ class TagCache: |
|
|
|
with open(fname, 'wb') as fp: |
|
|
|
fp.write(_asn1coder.dumps(cache)) |
|
|
|
|
|
|
|
def _get_paths(options): |
|
|
|
identfname = os.path.expanduser('~/.medashare_identity.pasn1') |
|
|
|
storefname = os.path.expanduser('~/.medashare_store.sqlite3') |
|
|
|
cachefname = os.path.expanduser('~/.medashare_cache.pasn1') |
|
|
|
|
|
|
|
return identfname, storefname, cachefname |
|
|
|
|
|
|
|
def init_datastructs(f): |
|
|
|
@functools.wraps(f) |
|
|
|
def wrapper(options): |
|
|
|
|
|
|
|
identfname = os.path.expanduser('~/.medashare_identity.pasn1') |
|
|
|
storefname = os.path.expanduser('~/.medashare_store.sqlite3') |
|
|
|
cachefname = os.path.expanduser('~/.medashare_cache.pasn1') |
|
|
|
identfname, storefname, cachefname = _get_paths(options) |
|
|
|
|
|
|
|
# create the persona |
|
|
|
try: |
|
|
@@ -806,7 +811,7 @@ def init_datastructs(f): |
|
|
|
return wrapper |
|
|
|
|
|
|
|
def cmd_genident(options): |
|
|
|
identfname = os.path.expanduser('~/.medashare_identity.pasn1') |
|
|
|
identfname, _, _ = _get_paths(options) |
|
|
|
|
|
|
|
if os.path.exists(identfname): |
|
|
|
print('Error: Identity already created.', file=sys.stderr) |
|
|
@@ -820,7 +825,7 @@ def cmd_genident(options): |
|
|
|
persona.store(identfname) |
|
|
|
|
|
|
|
def cmd_ident(options): |
|
|
|
identfname = os.path.expanduser('~/.medashare_identity.pasn1') |
|
|
|
identfname, _, _ = _get_paths(options) |
|
|
|
|
|
|
|
persona = Persona.load(identfname) |
|
|
|
|
|
|
@@ -835,7 +840,7 @@ def cmd_ident(options): |
|
|
|
print('%s:\t%s' % (k, v)) |
|
|
|
|
|
|
|
def cmd_pubkey(options): |
|
|
|
identfname = os.path.expanduser('~/.medashare_identity.pasn1') |
|
|
|
identfname, _, _ = _get_paths(options) |
|
|
|
|
|
|
|
persona = Persona.load(identfname) |
|
|
|
|
|
|
@@ -2110,7 +2115,9 @@ class _TestCases(unittest.TestCase): |
|
|
|
self.assertEqual(stdout.getvalue(), '') |
|
|
|
|
|
|
|
# looks up the correct file |
|
|
|
eu.assert_called_with('~/.medashare_identity.pasn1') |
|
|
|
eu.assert_any_call('~/.medashare_identity.pasn1') |
|
|
|
eu.assert_any_call('~/.medashare_store.sqlite3') |
|
|
|
eu.assert_any_call('~/.medashare_cache.pasn1') |
|
|
|
|
|
|
|
# and that the identity |
|
|
|
persona = Persona.load(identfname) |
|
|
@@ -2133,7 +2140,7 @@ class _TestCases(unittest.TestCase): |
|
|
|
'Error: Identity already created.\n') |
|
|
|
|
|
|
|
# and looked up the correct file |
|
|
|
eu.assert_called_with('~/.medashare_identity.pasn1') |
|
|
|
eu.assert_any_call('~/.medashare_identity.pasn1') |
|
|
|
|
|
|
|
# that when updating the identity |
|
|
|
with mock.patch('sys.stdout', io.StringIO()) as stdout, mock.patch('sys.argv', [ 'progname', 'ident', 'name=Changed Name' ]) as argv: |
|
|
@@ -2143,7 +2150,7 @@ class _TestCases(unittest.TestCase): |
|
|
|
self.assertEqual(stdout.getvalue(), '') |
|
|
|
|
|
|
|
# and looked up the correct file |
|
|
|
eu.assert_called_with('~/.medashare_identity.pasn1') |
|
|
|
eu.assert_any_call('~/.medashare_identity.pasn1') |
|
|
|
|
|
|
|
npersona = Persona.load(identfname) |
|
|
|
nident = npersona.get_identity() |
|
|
|