| @@ -774,11 +774,17 @@ class TagCache: | |||||
| fp.write(_asn1coder.dumps(cache)) | fp.write(_asn1coder.dumps(cache)) | ||||
| def _get_paths(options): | 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') | |||||
| fnames = ( | |||||
| '.medashare_identity.pasn1', | |||||
| '.medashare_store.sqlite3', | |||||
| '.medashare_cache.pasn1' ) | |||||
| return identfname, storefname, cachefname | |||||
| if 'MEDASHARE_PATH' in os.environ: | |||||
| return ( os.path.expanduser( | |||||
| os.path.join(os.environ['MEDASHARE_PATH'], x)) for x in | |||||
| fnames ) | |||||
| return ( os.path.expanduser('~/' + x) for x in fnames ) | |||||
| def init_datastructs(f): | def init_datastructs(f): | ||||
| @functools.wraps(f) | @functools.wraps(f) | ||||
| @@ -1040,8 +1046,6 @@ def checkforfile(objstr, curfile, ask=False): | |||||
| @init_datastructs | @init_datastructs | ||||
| def cmd_interactive(options, persona, objstr, cache): | def cmd_interactive(options, persona, objstr, cache): | ||||
| cache = get_cache(options) | |||||
| files = [ pathlib.Path(x) for x in options.files ] | files = [ pathlib.Path(x) for x in options.files ] | ||||
| autoskip = True | autoskip = True | ||||
| @@ -2053,6 +2057,23 @@ class _TestCases(unittest.TestCase): | |||||
| for i in patches: | for i in patches: | ||||
| i.stop() | i.stop() | ||||
| def test_get_paths(self): | |||||
| # Test to make sure get paths works as expected. | |||||
| with mock.patch('os.path.expanduser') as eu: | |||||
| a, b, c = _get_paths(None) | |||||
| eu.assert_any_call('~/.medashare_identity.pasn1') | |||||
| eu.assert_any_call('~/.medashare_store.sqlite3') | |||||
| eu.assert_any_call('~/.medashare_cache.pasn1') | |||||
| pathpref = pathlib.Path('/somepath/somewhere') | |||||
| with mock.patch.dict(os.environ, dict(MEDASHARE_PATH=str(pathpref))): | |||||
| i, s, c = _get_paths(None) | |||||
| self.assertEqual(i, str(pathpref / '.medashare_identity.pasn1')) | |||||
| self.assertEqual(s, str(pathpref / '.medashare_store.sqlite3')) | |||||
| self.assertEqual(c, str(pathpref / '.medashare_cache.pasn1')) | |||||
| #@unittest.skip('temp') | #@unittest.skip('temp') | ||||
| def test_cmds(self): | def test_cmds(self): | ||||
| cmds = sorted(self.fixtures.glob('cmd.*.json')) | cmds = sorted(self.fixtures.glob('cmd.*.json')) | ||||